Magyar OCR C# és .NET nyelven
A dokumentum további verziói:
Az IronOCR egy C# szoftverkomponens, amely lehetővé teszi a .NET-kódolók számára, hogy 126 nyelven olvassák el a képek és a PDF dokumentumok szövegét, beleértve a magyar nyelvet is.
Ez a Tesseract fejlett villája, amelyet kizárólag a .NET fejlesztők számára fejlesztettek ki, és a sebesség és a pontosság szempontjából is rendszeresen felülmúlja a többi Tesseract motort.
Az IronOcr tartalma. Nyelvek. Magyar
Ez a csomag 52 OCR nyelvet tartalmaz a .NET számára:
- Magyar
- HungarianBest
- HungarianFast
Letöltés
Magyar Nyelvcsomag [magyar]
* Download as Postai irányítószám
* Install with https://www.nuget.org/packages/IronOcr.Languages.Hungarian/ NuGet
Telepítés
Az első dolog, amit meg kell tennünk, telepítenie kell a magyar OCR csomagunkat a .NET projektjébe.
PM> Install-Package IronOCR.Languages.Hungarian
Kódpélda
Ez a C# kód példa magyar nyelvű szöveget olvas le egy Image vagy PDF dokumentumról.
// Add the IronOcr namespace to use the OCR functionality.
using IronOcr;
var Ocr = new IronTesseract();
// Set the language to Hungarian for OCR processing
Ocr.Language = OcrLanguage.Hungarian;
// Use a using statement to properly dispose of the OcrInput
using (var Input = new OcrInput(@"images\Hungarian.png"))
{
// Read the text from the input image
var Result = Ocr.Read(Input);
// Store the extracted text
var AllText = Result.Text;
// Output the text or use it as needed
Console.WriteLine(AllText);
}
// Add the IronOcr namespace to use the OCR functionality.
using IronOcr;
var Ocr = new IronTesseract();
// Set the language to Hungarian for OCR processing
Ocr.Language = OcrLanguage.Hungarian;
// Use a using statement to properly dispose of the OcrInput
using (var Input = new OcrInput(@"images\Hungarian.png"))
{
// Read the text from the input image
var Result = Ocr.Read(Input);
// Store the extracted text
var AllText = Result.Text;
// Output the text or use it as needed
Console.WriteLine(AllText);
}
' Add the IronOcr namespace to use the OCR functionality.
Imports IronOcr
Private Ocr = New IronTesseract()
' Set the language to Hungarian for OCR processing
Ocr.Language = OcrLanguage.Hungarian
' Use a using statement to properly dispose of the OcrInput
Using Input = New OcrInput("images\Hungarian.png")
' Read the text from the input image
Dim Result = Ocr.Read(Input)
' Store the extracted text
Dim AllText = Result.Text
' Output the text or use it as needed
Console.WriteLine(AllText)
End Using
Miért válassza az IronOCR-t?
Az IronOCR egy könnyen telepíthető, teljes és jól dokumentált .NET szoftverkönyvtár.
Válassza az IronOCR lehetőséget, ha 99,8% + OCR pontosságot szeretne elérni, anélkül, hogy bármilyen külső webszolgáltatást, folyamatos díjakat vagy bizalmas dokumentumokat küldene az interneten.
Miért választják a C# fejlesztők az IronOCR-t a Vanilla Tesseract helyett:
- Telepítés egyetlen DLL-ként vagy NuGet-ként
- A dobozból kivéve a Tesseract 5, 4 és 3 motorokat.
- A pontosság 99,8% -kal jelentősen felülmúlja a szokásos Tesseractot.
- Lángoló sebesség és MultiThreading
- Kompatibilis az MVC, a WebApp, az asztali, a konzol és a kiszolgálóalkalmazásokkal
- Nincs Exes vagy C++ kód, amellyel működhetne
- Teljes PDF OCR támogatás
- Szinte bármilyen képfájl vagy PDF OCR végrehajtásához
- Teljes .NET Core, Standard és FrameWork támogatás
- Telepítse Windows, Mac, Linux, Azure, Docker, Lambda, AWS rendszereken
- Olvassa el a vonalkódokat és a QR-kódokat
- Exportálja az OCR-t XHTML-be
- Exportálja az OCR-t kereshető PDF dokumentumokba
- Többszálas támogatás
- 126 nemzetközi nyelv, mindezeket NuGet vagy OcrData fájlokon keresztül kezelik
- Kivonat képek, koordináták, statisztikák és betűtípusok. Nem csak szöveg.
- Használható a Tesseract OCR terjesztésére kereskedelmi és saját alkalmazásokban.
A vas OCR akkor világít, ha valós képekkel és tökéletlen dokumentumokkal dolgozik, például fényképekkel, vagy alacsony felbontású beolvasásokkal, amelyek digitális zajjal vagy tökéletlenséggel járhatnak.
A .NET platform egyéb ingyenes OCR könyvtárai, mint például a .net tesseract API-k és a webszolgáltatások, nem teljesítenek ilyen jól a valós világban.
OCR a Tesseract 5-tel - Kezdje a kódolást C#-ben
Az alábbi kódminta megmutatja, hogy a C# vagy a VB .NET használatával milyen könnyen olvasható szöveg egy képből.
Egysoros
// Read text directly from an image with a single line of code
string Text = new IronTesseract().Read(@"img\Screenshot.png").Text;
// Read text directly from an image with a single line of code
string Text = new IronTesseract().Read(@"img\Screenshot.png").Text;
' Read text directly from an image with a single line of code
Dim Text As String = (New IronTesseract()).Read("img\Screenshot.png").Text
Konfigurálható Hello World
// Importing IronOcr library
using IronOcr;
// Initialize IronTesseract for OCR processing
var Ocr = new IronTesseract();
// Set the language to Hungarian
Ocr.Language = OcrLanguage.Hungarian;
// Using a using statement to ensure resources are properly disposed
using (var Input = new OcrInput())
{
// Add an image to the OCR input
Input.AddImage("images/sample.jpeg");
// ... you can add as many images as you want
// Perform OCR and retrieve the result
var Result = Ocr.Read(Input);
// Print the OCR result text
Console.WriteLine(Result.Text);
}
// Importing IronOcr library
using IronOcr;
// Initialize IronTesseract for OCR processing
var Ocr = new IronTesseract();
// Set the language to Hungarian
Ocr.Language = OcrLanguage.Hungarian;
// Using a using statement to ensure resources are properly disposed
using (var Input = new OcrInput())
{
// Add an image to the OCR input
Input.AddImage("images/sample.jpeg");
// ... you can add as many images as you want
// Perform OCR and retrieve the result
var Result = Ocr.Read(Input);
// Print the OCR result text
Console.WriteLine(Result.Text);
}
' Importing IronOcr library
Imports IronOcr
' Initialize IronTesseract for OCR processing
Private Ocr = New IronTesseract()
' Set the language to Hungarian
Ocr.Language = OcrLanguage.Hungarian
' Using a using statement to ensure resources are properly disposed
Using Input = New OcrInput()
' Add an image to the OCR input
Input.AddImage("images/sample.jpeg")
' ... you can add as many images as you want
' Perform OCR and retrieve the result
Dim Result = Ocr.Read(Input)
' Print the OCR result text
Console.WriteLine(Result.Text)
End Using
C# PDF OCR
Ugyanez a megközelítés hasonlóan alkalmazható bármilyen PDF dokumentum szövegének kinyerésére.
// Initialize IronTesseract for PDF OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement to handle OcrInput disposal
using (var input = new OcrInput())
{
// Add PDF to the input; specify password if needed
input.AddPdf("example.pdf", "password");
// Kiválaszthatunk konkrét PDF oldalszámokat is az OCR számára
// Perform OCR on the input
var Result = Ocr.Read(input);
// Output the OCR result text
Console.WriteLine(Result.Text);
// Output the number of pages processed
Console.WriteLine($"{Result.Pages.Count()} Pages");
// 1 oldal a PDF minden oldalához
}
// Initialize IronTesseract for PDF OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement to handle OcrInput disposal
using (var input = new OcrInput())
{
// Add PDF to the input; specify password if needed
input.AddPdf("example.pdf", "password");
// Kiválaszthatunk konkrét PDF oldalszámokat is az OCR számára
// Perform OCR on the input
var Result = Ocr.Read(input);
// Output the OCR result text
Console.WriteLine(Result.Text);
// Output the number of pages processed
Console.WriteLine($"{Result.Pages.Count()} Pages");
// 1 oldal a PDF minden oldalához
}
' Initialize IronTesseract for PDF OCR
Dim Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Hungarian
' Using statement to handle OcrInput disposal
Using input = New OcrInput()
' Add PDF to the input; specify password if needed
input.AddPdf("example.pdf", "password")
' Kiválaszthatunk konkrét PDF oldalszámokat is az OCR számára
' Perform OCR on the input
Dim Result = Ocr.Read(input)
' Output the OCR result text
Console.WriteLine(Result.Text)
' Output the number of pages processed
Console.WriteLine($"{Result.Pages.Count()} Pages")
' 1 oldal a PDF minden oldalához
End Using
OCR többoldalas TIFF-ekhez
OCR TIFF fájlformátum olvasása, többoldalas dokumentumokkal együtt. A TIFF közvetlenül konvertálható kereshető szöveget tartalmazó PDF fájlokká is.
using IronOcr;
// Initialize IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement for managing resources
using (var Input = new OcrInput())
{
// Add multi-frame TIFF file for OCR
Input.AddMultiFrameTiff("multi - frame.tiff");
// Perform OCR and retrieve the result
var Result = Ocr.Read(Input);
// Output the OCR result text
Console.WriteLine(Result.Text);
}
using IronOcr;
// Initialize IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement for managing resources
using (var Input = new OcrInput())
{
// Add multi-frame TIFF file for OCR
Input.AddMultiFrameTiff("multi - frame.tiff");
// Perform OCR and retrieve the result
var Result = Ocr.Read(Input);
// Output the OCR result text
Console.WriteLine(Result.Text);
}
Imports IronOcr
' Initialize IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Hungarian
' Using statement for managing resources
Using Input = New OcrInput()
' Add multi-frame TIFF file for OCR
Input.AddMultiFrameTiff("multi - frame.tiff")
' Perform OCR and retrieve the result
Dim Result = Ocr.Read(Input)
' Output the OCR result text
Console.WriteLine(Result.Text)
End Using
Vonalkódok és QR
Az IronOCR egyedülálló tulajdonsága, hogy vonalkódokat és QR-kódokat tud olvasni a dokumentumokból, miközben szöveget keres. Az OcrResult.OcrBarcode
osztály OcrResult.OcrBarcode
részletes információkat nyújtanak a fejlesztőnek az egyes beolvasott vonalkódokról.
// Importing IronOcr library
using IronOcr;
// Initialize IronTesseract with barcode reading enabled
var Ocr = new IronTesseract();
Ocr.Configuration.ReadBarCodes = true;
// Using statement for managing input resources
using (var input = new OcrInput())
{
// Add an image containing a barcode
input.AddImage("img/Barcode.png");
// Perform OCR operation
var Result = Ocr.Read(input);
// Iterate through each barcode found and print its value
foreach (var Barcode in Result.Barcodes)
{
Console.WriteLine(Barcode.Value);
// Típus és elhelyezkedés tulajdonságai is ki vannak téve
}
}
// Importing IronOcr library
using IronOcr;
// Initialize IronTesseract with barcode reading enabled
var Ocr = new IronTesseract();
Ocr.Configuration.ReadBarCodes = true;
// Using statement for managing input resources
using (var input = new OcrInput())
{
// Add an image containing a barcode
input.AddImage("img/Barcode.png");
// Perform OCR operation
var Result = Ocr.Read(input);
// Iterate through each barcode found and print its value
foreach (var Barcode in Result.Barcodes)
{
Console.WriteLine(Barcode.Value);
// Típus és elhelyezkedés tulajdonságai is ki vannak téve
}
}
' Importing IronOcr library
Imports IronOcr
' Initialize IronTesseract with barcode reading enabled
Private Ocr = New IronTesseract()
Ocr.Configuration.ReadBarCodes = True
' Using statement for managing input resources
Using input = New OcrInput()
' Add an image containing a barcode
input.AddImage("img/Barcode.png")
' Perform OCR operation
Dim Result = Ocr.Read(input)
' Iterate through each barcode found and print its value
For Each Barcode In Result.Barcodes
Console.WriteLine(Barcode.Value)
' Típus és elhelyezkedés tulajdonságai is ki vannak téve
Next Barcode
End Using
OCR a képek meghatározott területein
Az IronOCR összes szkennelési és olvasási módja lehetővé teszi, hogy pontosan meghatározzuk az oldal vagy oldalak mely részéből szeretnénk szöveget olvasni. Ez nagyon hasznos, ha szabványosított űrlapokat vizsgálunk, és nagyon sok időt takaríthat meg, és javíthatja a hatékonyságot.
A vágási régiók használatához hozzá kell adnunk egy rendszer hivatkozást a System.Drawing
, hogy használhassuk a System.Drawing.Rectangle
objektumot.
using IronOcr;
using System.Drawing; // For defining the rectangle area
// Initialize IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement to ensure disposal of resources
using (var Input = new OcrInput())
{
// Define a rectangular region for OCR scanning
var ContentArea = new Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
// A méretek px-ben vannak megadva
// Add the image and specify the region for OCR
Input.Add("document.png", ContentArea);
// Perform the OCR operation
var Result = Ocr.Read(Input);
// Output the result from the specified area
Console.WriteLine(Result.Text);
}
using IronOcr;
using System.Drawing; // For defining the rectangle area
// Initialize IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement to ensure disposal of resources
using (var Input = new OcrInput())
{
// Define a rectangular region for OCR scanning
var ContentArea = new Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
// A méretek px-ben vannak megadva
// Add the image and specify the region for OCR
Input.Add("document.png", ContentArea);
// Perform the OCR operation
var Result = Ocr.Read(Input);
// Output the result from the specified area
Console.WriteLine(Result.Text);
}
Imports IronOcr
Imports System.Drawing ' For defining the rectangle area
' Initialize IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Hungarian
' Using statement to ensure disposal of resources
Using Input = New OcrInput()
' Define a rectangular region for OCR scanning
Dim ContentArea = New Rectangle() With {
.X = 215,
.Y = 1250,
.Height = 280,
.Width = 1335
}
' A méretek px-ben vannak megadva
' Add the image and specify the region for OCR
Input.Add("document.png", ContentArea)
' Perform the OCR operation
Dim Result = Ocr.Read(Input)
' Output the result from the specified area
Console.WriteLine(Result.Text)
End Using
OCR alacsony minőségű vizsgálatokhoz
Az IronOCR OcrInput
osztály javíthatja azokat a beolvasásokat, amelyeket a normál Tesseract nem tud olvasni.
using IronOcr;
// Initialize IronTesseract for OCR with low-quality image handling
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement to handle Input disposal
using (var Input = new OcrInput(@"img\Potter.LowQuality.tiff"))
{
// Improve image quality: DeNoise reduces digital noise
Input.DeNoise();
// Deskew corrects rotation and perspective issues
Input.Deskew();
// Perform OCR on the input
var Result = Ocr.Read(Input);
// Output the OCR result text
Console.WriteLine(Result.Text);
}
using IronOcr;
// Initialize IronTesseract for OCR with low-quality image handling
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement to handle Input disposal
using (var Input = new OcrInput(@"img\Potter.LowQuality.tiff"))
{
// Improve image quality: DeNoise reduces digital noise
Input.DeNoise();
// Deskew corrects rotation and perspective issues
Input.Deskew();
// Perform OCR on the input
var Result = Ocr.Read(Input);
// Output the OCR result text
Console.WriteLine(Result.Text);
}
Imports IronOcr
' Initialize IronTesseract for OCR with low-quality image handling
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Hungarian
' Using statement to handle Input disposal
Using Input = New OcrInput("img\Potter.LowQuality.tiff")
' Improve image quality: DeNoise reduces digital noise
Input.DeNoise()
' Deskew corrects rotation and perspective issues
Input.Deskew()
' Perform OCR on the input
Dim Result = Ocr.Read(Input)
' Output the OCR result text
Console.WriteLine(Result.Text)
End Using
Exportálja az OCR-eredményeket kereshető PDF-fájlként
Kép PDF-be másolható szöveges karakterláncokkal. Keresőmotorok és adatbázisok indexelhetik.
using IronOcr;
// Initialize IronTesseract for OCR PDF conversion
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement for managing OcrInput resources
using (var Input = new OcrInput())
{
// Set the title for the PDF document
Input.Title = "Quarterly Report";
// Add images to be included in the PDF
Input.AddImage("image1.jpeg");
Input.AddImage("image2.png");
Input.AddImage("image3.gif");
// Perform OCR and save the result as a searchable PDF
var Result = Ocr.Read(Input);
Result.SaveAsSearchablePdf("searchable.pdf");
}
using IronOcr;
// Initialize IronTesseract for OCR PDF conversion
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement for managing OcrInput resources
using (var Input = new OcrInput())
{
// Set the title for the PDF document
Input.Title = "Quarterly Report";
// Add images to be included in the PDF
Input.AddImage("image1.jpeg");
Input.AddImage("image2.png");
Input.AddImage("image3.gif");
// Perform OCR and save the result as a searchable PDF
var Result = Ocr.Read(Input);
Result.SaveAsSearchablePdf("searchable.pdf");
}
Imports IronOcr
' Initialize IronTesseract for OCR PDF conversion
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Hungarian
' Using statement for managing OcrInput resources
Using Input = New OcrInput()
' Set the title for the PDF document
Input.Title = "Quarterly Report"
' Add images to be included in the PDF
Input.AddImage("image1.jpeg")
Input.AddImage("image2.png")
Input.AddImage("image3.gif")
' Perform OCR and save the result as a searchable PDF
Dim Result = Ocr.Read(Input)
Result.SaveAsSearchablePdf("searchable.pdf")
End Using
TIFF - kereshető PDF-konvertálás
Konvertálja a TIFF dokumentumot (vagy bármilyen képfájl-csoportot) közvetlenül kereshető PDF-be, amelyet az intranet, a webhely és a Google keresőmotorjai indexelhetnek.
using IronOcr;
// Initialize IronTesseract for TIFF to PDF conversion
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement for managing input resources
using (var Input = new OcrInput())
{
// Add a multi-frame TIFF to the OCR input
Input.AddMultiFrameTiff("example.tiff");
// Perform OCR, save as a searchable PDF
var Result = Ocr.Read(Input).SaveAsSearchablePdf("searchable.pdf");
}
using IronOcr;
// Initialize IronTesseract for TIFF to PDF conversion
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement for managing input resources
using (var Input = new OcrInput())
{
// Add a multi-frame TIFF to the OCR input
Input.AddMultiFrameTiff("example.tiff");
// Perform OCR, save as a searchable PDF
var Result = Ocr.Read(Input).SaveAsSearchablePdf("searchable.pdf");
}
Imports IronOcr
' Initialize IronTesseract for TIFF to PDF conversion
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Hungarian
' Using statement for managing input resources
Using Input = New OcrInput()
' Add a multi-frame TIFF to the OCR input
Input.AddMultiFrameTiff("example.tiff")
' Perform OCR, save as a searchable PDF
Dim Result = Ocr.Read(Input).SaveAsSearchablePdf("searchable.pdf")
End Using
Exportálja az OCR eredményeket HTML formátumban
OCR kép XHTML konvertálás.
using IronOcr;
// Initialize IronTesseract for OCR to HTML
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement to manage input resources
using (var Input = new OcrInput())
{
// Set the HTML title
Input.Title = "Html Title";
// Add images to be OCR processed
Input.AddImage("image1.jpeg");
// Conduct OCR and save results as an XHTML file
var Result = Ocr.Read(Input);
Result.SaveAsHocrFile("results.html");
}
using IronOcr;
// Initialize IronTesseract for OCR to HTML
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Using statement to manage input resources
using (var Input = new OcrInput())
{
// Set the HTML title
Input.Title = "Html Title";
// Add images to be OCR processed
Input.AddImage("image1.jpeg");
// Conduct OCR and save results as an XHTML file
var Result = Ocr.Read(Input);
Result.SaveAsHocrFile("results.html");
}
Imports IronOcr
' Initialize IronTesseract for OCR to HTML
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Hungarian
' Using statement to manage input resources
Using Input = New OcrInput()
' Set the HTML title
Input.Title = "Html Title"
' Add images to be OCR processed
Input.AddImage("image1.jpeg")
' Conduct OCR and save results as an XHTML file
Dim Result = Ocr.Read(Input)
Result.SaveAsHocrFile("results.html")
End Using
OCR képjavító szűrők
Az IronOCR egyedülálló szűrőket biztosít az OcrInput
objektumokhoz az OCR teljesítményének javítása érdekében.
Képjavító kód példa
Az OCR bemeneti képeket jobb minőségűvé teszi, hogy jobb, gyorsabb OCR eredményeket hozzon létre.
using IronOcr;
// Initialize IronTesseract for OCR operation
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Manage the input resource with a using statement
using (var Input = new OcrInput(@"LowQuality.jpeg"))
{
// Improve image quality: DeNoise and Deskew
Input.DeNoise(); // Reduces noise
Input.Deskew(); // Corrects skewing
// Perform OCR and obtain the result
var Result = Ocr.Read(Input);
// Output the OCR text result
Console.WriteLine(Result.Text);
}
using IronOcr;
// Initialize IronTesseract for OCR operation
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
// Manage the input resource with a using statement
using (var Input = new OcrInput(@"LowQuality.jpeg"))
{
// Improve image quality: DeNoise and Deskew
Input.DeNoise(); // Reduces noise
Input.Deskew(); // Corrects skewing
// Perform OCR and obtain the result
var Result = Ocr.Read(Input);
// Output the OCR text result
Console.WriteLine(Result.Text);
}
Imports IronOcr
' Initialize IronTesseract for OCR operation
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Hungarian
' Manage the input resource with a using statement
Using Input = New OcrInput("LowQuality.jpeg")
' Improve image quality: DeNoise and Deskew
Input.DeNoise() ' Reduces noise
Input.Deskew() ' Corrects skewing
' Perform OCR and obtain the result
Dim Result = Ocr.Read(Input)
' Output the OCR text result
Console.WriteLine(Result.Text)
End Using
OCR képszűrők listája
Az OCR teljesítményének növelése érdekében az IronOCR-be beépített bemeneti szűrők a következők:
- OcrInput.Rotate (double degrees) - A képeket több fokkal elforgatja az óramutató járásával megegyező irányba. Az óramutató járásával ellentétes irányba használjon negatív számokat.
- OcrInput.Binarize () - Ez a képszűrő minden képpontot fekete vagy fehér színűvé tesz, középút nélkül. Javíthatja az OCR-teljesítmény eseteit, amikor a szöveg nagyon alacsony kontrasztú a háttérrel.
- OcrInput.ToGrayScale () - Ez a képszűrő minden pixelt szürkeárnyalatos árnyalattá alakít. Nem valószínű, hogy javítja az OCR pontosságát, de javíthatja a sebességet.
- OcrInput.Contrast () - Automatikusan növeli a kontrasztot. Ez a szűrő alacsony kontrasztú szkenneléseknél gyakran javítja az OCR sebességét és pontosságát.
- OcrInput.DeNoise () - Eltávolítja a digitális zajt. Ezt a szűrőt csak ott szabad használni, ahol zaj várható.
- OcrInput.Invert () - Minden színt megfordít. Pl. A fehér feketévé válik: a fekete fehérré válik.
- OcrInput.Dilate () - Haladó morfológia. A tágulás pixeleket ad hozzá a képen lévő objektumok határaihoz. Erode-val szemben.
- OcrInput.Erode () - Haladó morfológia. Az erózió eltávolítja a képpontokat az objektumhatárokon.
- OcrInput.Deskew () - Elforgat egy képet, így az a helyes út felfelé és merőleges. Ez nagyon hasznos az OCR esetében, mert a ferde beolvasások Tesseract toleranciája akár 5 fok is lehet.
- OcrInput.DeepCleanBackgroundNoise () - Erős háttérzaj eltávolítás. Csak akkor használja ezt a szűrőt, ha szélsőséges dokumentum háttérzaj ismert, mert ez a szűrő a tiszta dokumentumok OCR-pontosságának csökkenését is megkockáztathatja, és nagyon CPU-költséges.
- OcrInput.EnhanceResolution - Fokozza az alacsony minőségű képek felbontását. Erre a szűrőre gyakran nincs szükség, mert az OcrInput.MinimumDPI és az OcrInput.TargetDPI automatikusan elkapja és megoldja az alacsony felbontású bemeneteket.
CleanBackgroundNoise. Ez egy kissé időigényes beállítás; ugyanakkor lehetővé teszi a könyvtár számára, hogy automatikusan megtisztítsa a digitális zajt, a papír gyűrődéseit és egyéb hiányosságait egy digitális képen belül, ami egyébként képtelenné tenné a többi OCR könyvtár olvasására.
Az EnhanceContrast egy olyan beállítás, amely miatt az IronOCR automatikusan megnöveli a szöveg kontrasztját a kép hátterében, növelve az OCR pontosságát, és általában növelve az OCR teljesítményét és sebességét.
Az EnhanceResolution egy olyan beállítás, amely automatikusan észleli az alacsony felbontású (275 dpi alatti) képeket, automatikusan felnagyítja a képet, majd az egész szöveget élesíti, hogy az OCR könyvtár tökéletesen olvasható legyen. Bár ez a művelet önmagában időigényes, általában csökkenti a kép OCR-műveletének teljes idejét.
Nyelv IronOCR 22 nemzetközi nyelvcsomagot támogat, és a nyelvi beállítással kiválasztható egy vagy több nyelv, amelyet alkalmazni kell egy OCR művelethez.
Stratégia Az IronOCR két stratégiát támogat. Választhatunk egy gyors és kevésbé pontos dokumentum-beolvasást, vagy egy olyan fejlett stratégiát használunk, amely néhány mesterséges intelligencia-modellt használ az OCR-szöveg pontosságának automatikus javításához azáltal, hogy a szavak statisztikai viszonyát egy mondatban vizsgálja.
A ColorSpace egy olyan beállítás, amellyel választhatunk szürkeárnyalatos vagy színes OCR-t. Általában a szürkeárnyalatos a legjobb megoldás. Azonban néha, ha vannak hasonló árnyalatú, de nagyon eltérő színű szövegek vagy hátterek, akkor a színes színtér jobb eredményt nyújt.
DetectWhiteTextOnDarkBackgrounds. Általában az összes OCR könyvtár arra számít, hogy fehér alapon fekete szöveget lát. Ez a beállítás lehetővé teszi, hogy az IronOCR automatikusan felismerje a negatívokat vagy a fehér szövegű sötét oldalakat, és elolvassa azokat.
InputImageType. Ez a beállítás lehetővé teszi a fejlesztő számára, hogy irányítsa az OCR könyvtárat abban, hogy teljes dokumentumot vagy részletet, például képernyőképet néz.
A RotateAndStraighten egy olyan speciális beállítás, amely lehetővé teszi az IronOCR számára azt az egyedülálló képességet, hogy elolvassa azokat a dokumentumokat, amelyek nemcsak el vannak forgatva, de esetleg perspektívát is tartalmaznak, például a szöveges dokumentumok fényképeit.
A ReadBarcodes egy hasznos szolgáltatás, amely lehetővé teszi az IronOCR számára, hogy automatikusan olvassa a vonalkódokat és a QR-kódokat az oldalakon, miközben szövegeket is olvas, anélkül, hogy további jelentős időterhelést jelentene.
Színmélység. Ez a beállítás határozza meg, hogy az OCR-könyvtár pixelenként hány bitet használjon a szín mélységének meghatározásához. A nagyobb színmélység növelheti az OCR minőségét, de megnöveli az OCR művelet befejezéséhez szükséges időt is.
126 Nyelvcsomagok
Az IronOCR 126 nemzetközi nyelvet támogat nyelvcsomagokon keresztül, amelyeket DLL-ként terjesztenek, amelyek letölthetők erről a webhelyről, vagy a NuGet Package Manager-ből.
Nyelvek: német, francia, angol, kínai, japán és még sok más. Speciális nyelvi csomagok léteznek az MRZ útlevélhez, a MICR ellenőrzésekhez, a pénzügyi adatokhoz, a rendszámokhoz és még sok máshoz. Használhat bármilyen tesseract ".traineddata" fájlt is, beleértve azokat is, amelyeket maga készített.
Nyelv példa
Egyéb OCR nyelvek használata.
// using IronOcr;
// Import the Arabic language package using NuGet: PM> Install IronOcr.Languages.Arabic
// Initialize IronTesseract with Arabic language for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Arabic;
// Using statement for managing input resources
using (var input = new OcrInput())
{
// Add an image with Arabic text for OCR
input.AddImage("img/arabic.gif");
// Optionally apply image filters here for better recognition
// Even with low quality input, IronTesseract can outperform traditional Tesseract
// Perform OCR operation
var Result = Ocr.Read(input);
// Because the console might not easily print Arabic on Windows, save it to a file instead
Result.SaveAsTextFile("arabic.txt");
}
// using IronOcr;
// Import the Arabic language package using NuGet: PM> Install IronOcr.Languages.Arabic
// Initialize IronTesseract with Arabic language for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Arabic;
// Using statement for managing input resources
using (var input = new OcrInput())
{
// Add an image with Arabic text for OCR
input.AddImage("img/arabic.gif");
// Optionally apply image filters here for better recognition
// Even with low quality input, IronTesseract can outperform traditional Tesseract
// Perform OCR operation
var Result = Ocr.Read(input);
// Because the console might not easily print Arabic on Windows, save it to a file instead
Result.SaveAsTextFile("arabic.txt");
}
' using IronOcr;
' Import the Arabic language package using NuGet: PM> Install IronOcr.Languages.Arabic
' Initialize IronTesseract with Arabic language for OCR
Dim Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Arabic
' Using statement for managing input resources
Using input = New OcrInput()
' Add an image with Arabic text for OCR
input.AddImage("img/arabic.gif")
' Optionally apply image filters here for better recognition
' Even with low quality input, IronTesseract can outperform traditional Tesseract
' Perform OCR operation
Dim Result = Ocr.Read(input)
' Because the console might not easily print Arabic on Windows, save it to a file instead
Result.SaveAsTextFile("arabic.txt")
End Using
Többnyelvű példa
Lehetőség van OCR egyszerre több nyelv használatával is. Ez valóban segíthet az angol nyelvű metaadatok és URL-ek megszerzésében az Unicode dokumentumokban.
// using IronOcr;
// Install additional language package using NuGet: PM> Install IronOcr.Languages.ChineseSimplified
// Initialize IronTesseract with a primary language
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.ChineseSimplified;
// Add a secondary language for dual-language OCR capability
Ocr.AddSecondaryLanguage(OcrLanguage.Hungarian);
// Using statement for managing input resources
using (var input = new OcrInput())
{
// Add a document that contains multiple languages
input.Add("multi - language.pdf");
// Perform OCR operation
var Result = Ocr.Read(input);
// Save OCR text result to a file
Result.SaveAsTextFile("results.txt");
}
// using IronOcr;
// Install additional language package using NuGet: PM> Install IronOcr.Languages.ChineseSimplified
// Initialize IronTesseract with a primary language
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.ChineseSimplified;
// Add a secondary language for dual-language OCR capability
Ocr.AddSecondaryLanguage(OcrLanguage.Hungarian);
// Using statement for managing input resources
using (var input = new OcrInput())
{
// Add a document that contains multiple languages
input.Add("multi - language.pdf");
// Perform OCR operation
var Result = Ocr.Read(input);
// Save OCR text result to a file
Result.SaveAsTextFile("results.txt");
}
' using IronOcr;
' Install additional language package using NuGet: PM> Install IronOcr.Languages.ChineseSimplified
' Initialize IronTesseract with a primary language
Dim Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.ChineseSimplified
' Add a secondary language for dual-language OCR capability
Ocr.AddSecondaryLanguage(OcrLanguage.Hungarian)
' Using statement for managing input resources
Using input = New OcrInput()
' Add a document that contains multiple languages
input.Add("multi - language.pdf")
' Perform OCR operation
Dim Result = Ocr.Read(input)
' Save OCR text result to a file
Result.SaveAsTextFile("results.txt")
End Using
Részletes OCR eredmények objektumok
A Vas OCR minden OCR művelethez OCR eredmény objektumot ad vissza. A fejlesztők általában csak az objektum szövegtulajdonságát használják a képről beolvasott szöveg lekérésére. Az OCR eredmények DOM azonban ennél sokkal fejlettebb.
using IronOcr;
using System.Drawing; // Add a reference for Rectangle usage
// Initialize IronTesseract with specific configuration
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm;
// Enable barcode reading
Ocr.Configuration.ReadBarCodes = true;
// Using statement to manage input resources
using (var Input = new OcrInput(@"images\sample.tiff"))
{
// Read the input image and get the OCR result object
OcrResult Result = Ocr.Read(Input);
// Access detailed API with pages, words, barcodes, etc.
var Pages = Result.Pages;
var Words = Pages[0].Words;
var Barcodes = Result.Barcodes;
// Explore the robust detailed API for:
// - Pages, Blocks, Paragraphs, Lines, Words, Characters
// - Image Export, Font Coordinates, Statistical data
}
using IronOcr;
using System.Drawing; // Add a reference for Rectangle usage
// Initialize IronTesseract with specific configuration
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Hungarian;
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm;
// Enable barcode reading
Ocr.Configuration.ReadBarCodes = true;
// Using statement to manage input resources
using (var Input = new OcrInput(@"images\sample.tiff"))
{
// Read the input image and get the OCR result object
OcrResult Result = Ocr.Read(Input);
// Access detailed API with pages, words, barcodes, etc.
var Pages = Result.Pages;
var Words = Pages[0].Words;
var Barcodes = Result.Barcodes;
// Explore the robust detailed API for:
// - Pages, Blocks, Paragraphs, Lines, Words, Characters
// - Image Export, Font Coordinates, Statistical data
}
Imports IronOcr
Imports System.Drawing ' Add a reference for Rectangle usage
' Initialize IronTesseract with specific configuration
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Hungarian
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm
' Enable barcode reading
Ocr.Configuration.ReadBarCodes = True
' Using statement to manage input resources
Using Input = New OcrInput("images\sample.tiff")
' Read the input image and get the OCR result object
Dim Result As OcrResult = Ocr.Read(Input)
' Access detailed API with pages, words, barcodes, etc.
Dim Pages = Result.Pages
Dim Words = Pages(0).Words
Dim Barcodes = Result.Barcodes
' Explore the robust detailed API for:
' - Pages, Blocks, Paragraphs, Lines, Words, Characters
' - Image Export, Font Coordinates, Statistical data
End Using
Teljesítmény
Az IronOCR a dobozból működik, nincs szükség a bemeneti képek teljesítményének hangolására vagy erős módosítására.
A sebesség lángol: Az IronOcr.2020 + akár tízszer gyorsabb és több mint 250% -kal kevesebb hibát okoz, mint a korábbi buildek.
Tudj meg többet
Ha többet szeretne megtudni az OCR-ről C#, VB, F# vagy bármely más .NET nyelven, kérjük, olvassa el közösségi oktatóanyagainkat, amelyek valós példákat mutatnak be az IronOCR használatára, és megmutatják az árnyalatokat, hogyan lehet a legjobban kihozni ezt a könyvtárat.
A .NET fejlesztők számára teljes objektum-referencia is rendelkezésre áll.