Swahili 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 w C#, pozwalający programistom .NET na czytanie tekstu z obrazów i dokumentów PDF w 126 językach, w tym w suahili. Jest to zaawansowana gałąź Tesseract, zbudowana wyłącznie dla programistów .NET i regularnie przewyższa inne silniki Tesseract zarówno pod względem prędkości, jak i dokładności.

Zawartość IronOcr.Languages.Swahili

Ten pakiet zawiera 46 języków OCR dla .NET:

  • suahili
  • suahiliBest
  • suahiliFast

Pobieranie

Pakiet językowy suahili [Kiswahili]

  • Pobierz jako Zip
  • Zainstaluj za pomocą NuGet

Instalacja

Pierwszą rzeczą, którą musimy zrobić, jest zainstalowanie naszego pakietu OCR dla suahili w projekcie .NET.

Install-Package IronOcr.Languages.Swahili

Przyklad kodu

Ten przykład kodu C# odczytuje tekst w suahili z obrazu lub dokumentu PDF.

using IronOcr;

var Ocr = new IronTesseract();

// Set the OCR language to Swahili
Ocr.Language = OcrLanguage.Swahili;

// Create an OCR input for the image or PDF file
using (var Input = new OcrInput(@"images\Swahili.png"))
{
    // Perform OCR on the input image
    var Result = Ocr.Read(Input);

    // Retrieve the recognized text
    var AllText = Result.Text;

    // Output the recognized text to the console (optional)
    Console.WriteLine(AllText);
}
using IronOcr;

var Ocr = new IronTesseract();

// Set the OCR language to Swahili
Ocr.Language = OcrLanguage.Swahili;

// Create an OCR input for the image or PDF file
using (var Input = new OcrInput(@"images\Swahili.png"))
{
    // Perform OCR on the input image
    var Result = Ocr.Read(Input);

    // Retrieve the recognized text
    var AllText = Result.Text;

    // Output the recognized text to the console (optional)
    Console.WriteLine(AllText);
}
Imports IronOcr

Private Ocr = New IronTesseract()

' Set the OCR language to Swahili
Ocr.Language = OcrLanguage.Swahili

' Create an OCR input for the image or PDF file
Using Input = New OcrInput("images\Swahili.png")
	' Perform OCR on the input image
	Dim Result = Ocr.Read(Input)

	' Retrieve the recognized text
	Dim AllText = Result.Text

	' Output the recognized text to the console (optional)
	Console.WriteLine(AllText)
End Using
$vbLabelText   $csharpLabel

Wyjaśnienie:

  1. Użycie przestrzeni nazw IronOcr: Dołączamy przestrzeń nazw IronOcr, która zapewnia klasy i metody do operacji OCR.

  2. Inicjalizacja silnika OCR: Tworzymy instancję IronTesseract, będącą silnikiem OCR. Ustawienie jego języka na suahili umożliwia rozpoznawanie tekstu w suahili.

  3. Wejście OCR: Klasa OcrInput jest używana do określenia pliku (obrazu lub PDF), z którego chcemy wyodrębnić tekst.

  4. Odczyt OCR: Metoda Read przetwarza wejście i zwraca obiekt OcrResult zawierający rozpoznany tekst.

  5. Wynik: Rozpoznany tekst jest przechowywany w AllText, który może być użyty zgodnie z potrzebami. W tym przykładzie jest wyświetlany na konsoli w celach demonstracyjnych.