Bengali OCR in C# and .NET
Inne wersje tego dokumentu:
IronOCR to komponent oprogramowania C#, który pozwala programistom .NET odczytywać tekst z obrazów i dokumentów PDF w 126 językach, w tym w bengalskim. Jest to zaawansowany fork Tesseracta, zbudowany wyłącznie dla deweloperów .NET i regularnie przewyższający inne silniki Tesseract pod względem szybkości i dokładności.
Zawartość IronOcr.Languages.Bengali
Ten pakiet zawiera 114 języków OCR dla .NET:
- Bengali
- BengaliBest
- BengaliFast
- BengaliAlphabet
- BengaliAlphabetBest
- BengaliAlphabetFast
Pobieranie
Bengali Language Pack [Bangla]
Instalacja
Pierwszą rzeczą, którą musimy zrobić, to zainstalować nasz pakiet Bengali OCR w projekcie .NET.
Install-Package IronOcr.Languages.Bengali
Przyklad kodu
Przykład kodu C# czyta tekst w języku bengalskim z obrazu lub dokumentu 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
Wyjaśnienie
-
Importuj IronOcr: Zaczynamy od importu przestrzeni nazw
IronOcr, która zawiera klasy i metody niezbędne do wykonywania operacji OCR. -
Utwórz instancję IronTesseract: Tworzymy instancję
IronTesseract, która jest główną klasą do wykonywania OCR. -
Ustaw język: Ustawiamy język OCR na bengalski za pomocą
OcrLanguage.Bengali. -
OcrInput: Określamy ścieżkę do obrazu, z którego chcemy wyodrębnić tekst. Obiekt
OcrInputjest używany do ładowania i wstępnego przetwarzania pliku wejściowego. -
Czytaj i wyodrębnij tekst: Korzystając z metody
Read, przetwarzamy obraz, aby odczytać zawartość tekstową. Tekst jest przechowywany wResult.Text. - Wyprowadź tekst: Na koniec wyświetlamy wyodrębniony tekst w konsoli, aby zweryfikować wynik.

