Lao OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English
Inne wersje tego dokumentu:

IronOCR to komponent oprogramowania C#, który pozwala programistom .NET czytać teksty z obrazów i dokumentów PDF w 126 językach, w tym laotańskim.

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.Lao

Ten pakiet zawiera wiele modeli języka OCR dla .NET:

  • Lao
  • LaoBest
  • LaoFast
  • LaoAlphabet
  • LaoAlphabetBest
  • LaoAlphabetFast

Pobieranie

Lao Language Pack [ພາສາລາວ]

Instalacja

Pierwszą rzeczą, którą musimy zrobić, jest zainstalowanie pakietu OCR Lao w Twoim projekcie .NET.

Install-Package IronOcr.Languages.Lao

Przyklad kodu

Ten przykład kodu C# odczytuje tekst laotański z obrazu lub dokumentu PDF.

// Import the IronOcr namespace to use its OCR functionality
using IronOcr;

// Create a new IronTesseract instance
var Ocr = new IronTesseract();
// Set the OCR language to Lao
Ocr.Language = OcrLanguage.Lao;

// Use a using statement to ensure proper disposal of resources
using (var Input = new OcrInput(@"images\Lao.png"))
{
    // Perform OCR on the input image
    var Result = Ocr.Read(Input);
    // Extract all text from the OCR result
    var AllText = Result.Text;

    // Output the recognized text for verification
    Console.WriteLine(AllText);
}
// Import the IronOcr namespace to use its OCR functionality
using IronOcr;

// Create a new IronTesseract instance
var Ocr = new IronTesseract();
// Set the OCR language to Lao
Ocr.Language = OcrLanguage.Lao;

// Use a using statement to ensure proper disposal of resources
using (var Input = new OcrInput(@"images\Lao.png"))
{
    // Perform OCR on the input image
    var Result = Ocr.Read(Input);
    // Extract all text from the OCR result
    var AllText = Result.Text;

    // Output the recognized text for verification
    Console.WriteLine(AllText);
}
' Import the IronOcr namespace to use its OCR functionality
Imports IronOcr

' Create a new IronTesseract instance
Private Ocr = New IronTesseract()
' Set the OCR language to Lao
Ocr.Language = OcrLanguage.Lao

' Use a using statement to ensure proper disposal of resources
Using Input = New OcrInput("images\Lao.png")
	' Perform OCR on the input image
	Dim Result = Ocr.Read(Input)
	' Extract all text from the OCR result
	Dim AllText = Result.Text

	' Output the recognized text for verification
	Console.WriteLine(AllText)
End Using
$vbLabelText   $csharpLabel

Wyjaśnienie:

  • Kod ten pokazuje, jak skonfigurować i używać IronOCR do wykonywania OCR specyficznie dla języka laotańskiego.
  • IronTesseract to główna klasa używana do przeprowadzania operacji OCR.
  • Język jest ustawiony na laotański przy użyciu Ocr.Language.
  • OcrInput to klasa używana do ładowania obrazów lub dokumentów PDF do przetwarzania OCR.
  • Metoda Ocr.Read przetwarza dane wejściowe i zwraca wynik zawierający rozpoznany tekst.
  • Polecenie using zapewnia zwolnienie zasobów po użyciu.
  • Na koniec rozpoznany tekst jest drukowany na konsoli, aby zweryfikować wyjście.