Han Simplified Alphabet OCR in C# and .NET
IronOCR to komponent oprogramowania C# umożliwiający programistom .NET odczytywanie tekstu z obrazów i dokumentów PDF w 126 językach, w tym uproszczonym alfabecie Han.
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.Han
Ten pakiet zawiera 400 języków OCR dla .NET:
- HanSimplifiedAlphabet
- HanSimplifiedAlphabetBest
- HanSimplifiedAlphabetFast
- HanSimplifiedVerticalAlphabet
- HanSimplifiedVerticalAlphabetBest
- HanSimplifiedVerticalAlphabetFast
- HanTraditionalAlphabet
- HanTraditionalAlphabetBest
- HanTraditionalAlphabetFast
- HanTraditionalVerticalAlphabet
- HanTraditionalVerticalAlphabetBest
- HanTraditionalVerticalAlphabetFast
Pobieranie
Pakiet językowy uproszczonego alfabetu Han [Samhan]
- Download as [Zip](javascript:window.open("/csharp/ocr/packages/language-packs/Han.ocrdata.zip")
- Install with NuGet
Instalacja
Pierwszą rzeczą, którą musimy zrobić, jest zainstalowanie naszego pakietu OCR Uproszczony Alfabet Han do projektu .NET.
Uruchom następujące polecenie w konsoli menedżera pakietów:
Install-Package IronOcr.Languages.Han
Przyklad kodu
Ten przykład kodu C# odczytuje tekst uproszczonego alfabetu Han z obrazu lub dokumentu PDF.
// Reference the IronOcr library
using IronOcr;
class Program
{
static void Main()
{
// Create an IronTesseract OCR engine
var Ocr = new IronTesseract();
// Load the Han language for OCR processing
Ocr.Language = OcrLanguage.Han;
// Using a 'using' statement for resource management
using (var Input = new OcrInput(@"images\Han.png"))
{
// Process the image to extract text
var Result = Ocr.Read(Input);
// Retrieve and display the extracted text
string AllText = Result.Text;
System.Console.WriteLine(AllText);
}
}
}
// Reference the IronOcr library
using IronOcr;
class Program
{
static void Main()
{
// Create an IronTesseract OCR engine
var Ocr = new IronTesseract();
// Load the Han language for OCR processing
Ocr.Language = OcrLanguage.Han;
// Using a 'using' statement for resource management
using (var Input = new OcrInput(@"images\Han.png"))
{
// Process the image to extract text
var Result = Ocr.Read(Input);
// Retrieve and display the extracted text
string AllText = Result.Text;
System.Console.WriteLine(AllText);
}
}
}
' Reference the IronOcr library
Imports IronOcr
Friend Class Program
Shared Sub Main()
' Create an IronTesseract OCR engine
Dim Ocr = New IronTesseract()
' Load the Han language for OCR processing
Ocr.Language = OcrLanguage.Han
' Using a 'using' statement for resource management
Using Input = New OcrInput("images\Han.png")
' Process the image to extract text
Dim Result = Ocr.Read(Input)
' Retrieve and display the extracted text
Dim AllText As String = Result.Text
System.Console.WriteLine(AllText)
End Using
End Sub
End Class
Wyjaśnienie
- Zaczynamy od dołączenia biblioteki IronOCR, aby skorzystać z jej funkcji OCR.
- Tworzona jest instancja
IronTesseractw celu przetworzenia dokumentów graficznych/PDF. - Język dla procesu OCR jest ustawiony na
Hanprzy użyciuOcr.Language. - Obraz jest ładowany za pomocą
OcrInputi przetwarzany poprzez wywołanieOcr.Read(). - Wynik procesu OCR jest zapisywany w
Result.Text, który zawiera tekst wyodrębniony z dokumentu. - Na koniec drukujemy tekst na konsolę.
Należy upewnić się, że zastosowano odpowiednie dyrektywy using oraz efektywnie zarządzać zasobami za pomocą instrukcji using, zwłaszcza w przypadku zasobów niezarządzanych, takich jak strumienie plików.

