Persian OCR in C# and .NET
Outras versões deste documento:
O IronOCR é um componente de software C# que permite aos programadores .NET ler texto de imagens e documentos PDF em 126 idiomas, incluindo o persa.
Trata-se de uma versão avançada do Tesseract, criada exclusivamente para desenvolvedores .NET e que supera regularmente outros mecanismos do Tesseract em termos de velocidade e precisão.
Conteúdo de IronOcr.Languages.Persian
Este pacote contém 46 linguagens de OCR for .NET:
- Persa
- PersianBest
- PersianFast
Baixar
Pacote de idioma persa [فارسی]
Instalação
A primeira coisa que precisamos fazer é instalar nosso pacote de OCR em persa no seu projeto .NET.
PM> Install-Package IronOcr.Languages.Persian
Exemplo de código
Este exemplo de código C# lê texto em persa a partir de uma imagem ou 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 Class
O exemplo de código acima demonstra como utilizar a biblioteca IronOCR para realizar OCR em uma imagem em persa. É essencial ter o pacote de idioma persa instalado e o caminho para a imagem deve ser especificado corretamente. A operação de OCR é realizada dentro de uma declaração using para garantir o descarte adequado dos recursos.

