Swahili OCR in C# and .NET
Autres versions de ce document
IronOCR est un composant logiciel C# permettant aux développeurs .NET de lire du texte à partir d'images et de documents PDF dans 126 langues, dont le swahili. Il s'agit d'une version avancée de Tesseract, conçue exclusivement pour les développeurs .NET, et qui surpasse régulièrement les autres moteurs Tesseract en termes de vitesse et de précision.
Contenu de IronOcr.Languages.Swahili
Ce package contient 46 langues OCR for .NET :
- Swahili
- SwahiliBest
- SwahiliFast
Télécharger
Pack de langue swahili [Kiswahili]
Installation
La première chose à faire est d'installer notre package OCR swahili sur votre projet .NET.
Install-Package IronOcr.Languages.Swahili
Exemple de code
Cet exemple de code C# lit du texte swahili à partir d'une image ou d'un document 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
Explication :
-
Utilisation de l'espace de noms IronOCR : Nous incluons l'espace de noms
IronOcr, qui fournit des classes et des méthodes pour les opérations OCR. -
Initialisation du moteur OCR : Nous créons une instance de
IronTesseract, qui est le moteur OCR. En définissant sa langue sur le swahili, il peut reconnaître le texte swahili. -
Entrée OCR : La classe
OcrInputest utilisée pour spécifier le fichier (image ou PDF) à partir duquel nous voulons extraire du texte. -
Lecture OCR : La méthode
Readtraite l'entrée et renvoie un objetOcrResultcontenant le texte reconnu. - Sortie : Le texte reconnu est stocké dans
AllText, qui peut être utilisé selon les besoins. Dans cet exemple, le résultat est affiché sur la console à des fins de démonstration.

