OCR persa en C# y .NET
Other versions of this document:
IronOCR es un componente de software C# que permite a los desarrolladores de .NET leer texto de imágenes y documentos PDF en 126 idiomas, incluido el persa.
Es una rama avanzada de Tesseract, construida exclusivamente para desarrolladores de .NET y supera regularmente a otros motores de Tesseract tanto en velocidad como en precisión.
Contenido de IronOcr.Languages.Persian
Este paquete contiene 46 idiomas OCR para .NET:
- Persa
- PersaMejor
- PersaRápido
Descargar
Paquete de idioma persa [فارسی]
Instalación
Lo primero que debemos hacer es instalar nuestro paquete OCR Persa en su proyecto .NET.
PM> Install-Package IronOCR.Languages.Persian
Ejemplo de código
Este ejemplo de código C# lee texto en persa de una imagen o documento PDF.
// Install IronOcr.Languages.Persian package using NuGet Package Manager
// PM> Install-Package IronOcr.Languages.Persian
using IronOcr;
class Program
{
static void Main()
{
// Create a new instance of IronTesseract
var Ocr = new IronTesseract();
// Set the language to Persian
Ocr.Language = OcrLanguage.Persian;
// Load input image or PDF file
using (var Input = new OcrInput(@"images\Persian.png"))
{
// Perform OCR to read text from the image
var Result = Ocr.Read(Input);
// Extract the recognized text
var AllText = Result.Text;
// Display the extracted text
Console.WriteLine(AllText);
}
}
}// Install IronOcr.Languages.Persian package using NuGet Package Manager
// PM> Install-Package IronOcr.Languages.Persian
using IronOcr;
class Program
{
static void Main()
{
// Create a new instance of IronTesseract
var Ocr = new IronTesseract();
// Set the language to Persian
Ocr.Language = OcrLanguage.Persian;
// Load input image or PDF file
using (var Input = new OcrInput(@"images\Persian.png"))
{
// Perform OCR to read text from the image
var Result = Ocr.Read(Input);
// Extract the recognized text
var AllText = Result.Text;
// Display the extracted text
Console.WriteLine(AllText);
}
}
}' Install IronOcr.Languages.Persian package using NuGet Package Manager
' PM> Install-Package IronOcr.Languages.Persian
Imports IronOcr
Friend Class Program
Shared Sub Main()
' Create a new instance of IronTesseract
Dim Ocr = New IronTesseract()
' Set the language to Persian
Ocr.Language = OcrLanguage.Persian
' Load input image or PDF file
Using Input = New OcrInput("images\Persian.png")
' Perform OCR to read text from the image
Dim Result = Ocr.Read(Input)
' Extract the recognized text
Dim AllText = Result.Text
' Display the extracted text
Console.WriteLine(AllText)
End Using
End Sub
End ClassEl ejemplo de código anterior demuestra cómo utilizar la biblioteca IronOCR para realizar OCR en una imagen persa. Es esencial tener instalado el paquete de idioma persa y la ruta a la imagen debe especificarse correctamente. La operación de OCR se realiza dentro de una instrucción using para asegurar la correcta liberación de recursos.





