Bengali 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 bengali. 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 do IronOcr.Idiomas.Bengali
Este pacote contém 114 idiomas OCR for .NET:
- Bengali
- BengaliBest
- BengaliFast
- Alfabeto Bengali
- Melhor Alfabeto Bengali
- Alfabeto Bengali Rápido
Baixar
Pacote de Língua Bengali [Bangla]
Instalação
A primeira coisa que precisamos fazer é instalar nosso pacote de OCR para bengali em seu projeto .NET .
Install-Package IronOcr.Languages.Bengali
Exemplo de código
Este exemplo de código C# lê texto em bengali a partir de uma imagem ou documento PDF.
// Import the IronOcr namespace
using IronOcr;
class BengaliOcrExample
{
static void Main()
{
// Create an instance of IronTesseract
var Ocr = new IronTesseract();
// Specify the language for OCR
Ocr.Language = OcrLanguage.Bengali;
// Process the image and extract text
using (var Input = new OcrInput(@"images\Bengali.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Get the extracted text
var AllText = Result.Text;
// Output the extracted text to the console
System.Console.WriteLine(AllText);
}
}
}
// Import the IronOcr namespace
using IronOcr;
class BengaliOcrExample
{
static void Main()
{
// Create an instance of IronTesseract
var Ocr = new IronTesseract();
// Specify the language for OCR
Ocr.Language = OcrLanguage.Bengali;
// Process the image and extract text
using (var Input = new OcrInput(@"images\Bengali.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Get the extracted text
var AllText = Result.Text;
// Output the extracted text to the console
System.Console.WriteLine(AllText);
}
}
}
' Import the IronOcr namespace
Imports IronOcr
Friend Class BengaliOcrExample
Shared Sub Main()
' Create an instance of IronTesseract
Dim Ocr = New IronTesseract()
' Specify the language for OCR
Ocr.Language = OcrLanguage.Bengali
' Process the image and extract text
Using Input = New OcrInput("images\Bengali.png")
' Perform OCR on the input image
Dim Result = Ocr.Read(Input)
' Get the extracted text
Dim AllText = Result.Text
' Output the extracted text to the console
System.Console.WriteLine(AllText)
End Using
End Sub
End Class
Explicação
-
Importar IronOCR: Começamos importando o namespace
IronOcr, que contém classes e métodos necessários para executar operações de OCR. -
Criar Instância IronTesseract: Criamos uma instância de
IronTesseract, que é a principal classe para realizar OCR. -
Definir Idioma: Configuramos o idioma OCR para Bengali usando
OcrLanguage.Bengali. -
OcrInput: Especificamos o caminho para a imagem da qual queremos extrair o texto. Um objeto
OcrInputé usado para carregar e pré-processar o arquivo de entrada. -
Ler e Extrair Texto: Usando o método
Read, processamos a imagem para ler o conteúdo do texto. O texto é armazenado emResult.Text. - Texto de saída: Por fim, imprimimos o texto extraído no console para verificar a saída.

