Thai Alphabet OCR ในภาษา C#และ.NET

เวอรชนอน ๆ ของเอกสารน:

IronOCR เปนสวนประกอบซอฟตแวร C#ทชวยใหผเขารหส. NET สามารถอานขอความจากรปภาพและเอกสาร PDF ใน 126 ภาษารวมทงตวอกษรภาษาไทย

เปนทางแยกขนสงของ Tesseract ซงสรางขนสำหรบนกพฒนา. NET โดยเฉพาะและมประสทธภาพเหนอกวาเอนจน Tesseract อน ๆ เปนประจำทงในดานความเรวและความแมนยำ

เนอหาของ IronOcr.Languages.Thai

แพคเกจนประกอบดวย 96 OCR ภาษาสำหรบ. NET:

  • ไทย
  • ไทยเบสท
  • ไทยฟาสต
  • ThaiAlphabet
  • ThaiAlphabetBest
  • ThaiAlphabetFast

ดาวนโหลด

Thai Alphabet Language Pack [ไทย]
* Download as ซป
* Install with
https://www.nuget.org/packages/IronOcr.Languages.Thai/'> NuGet

การตดตง

สงแรกทเราตองทำคอตดตงแพคเกจ Thai Alphabet OCR ในโปรเจกต. NET ของคณ

PM> Install-Package IronOCR.Languages.Thai

ตวอยางรหส

ตวอยางรหส C#นอานขอความตวอกษรภาษาไทยจากเอกสารรปภาพหรอ PDF

// PM> Install-Package IronOCR.Languages.Thai
using IronOcr;

// Create an OCR object and specify the language
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Using an image input for OCR processing
using (var Input = new OcrInput(@"images\Thai.png"))
{
    // Read the input image and obtain the OCR result
    var Result = Ocr.Read(Input);
    // Retrieve all recognized text from the result
    var AllText = Result.Text;
    // Output the text or use it in further processing
    Console.WriteLine(AllText);
}
// PM> Install-Package IronOCR.Languages.Thai
using IronOcr;

// Create an OCR object and specify the language
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Using an image input for OCR processing
using (var Input = new OcrInput(@"images\Thai.png"))
{
    // Read the input image and obtain the OCR result
    var Result = Ocr.Read(Input);
    // Retrieve all recognized text from the result
    var AllText = Result.Text;
    // Output the text or use it in further processing
    Console.WriteLine(AllText);
}
' PM> Install-Package IronOCR.Languages.Thai
Imports IronOcr

' Create an OCR object and specify the language
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Using an image input for OCR processing
Using Input = New OcrInput("images\Thai.png")
	' Read the input image and obtain the OCR result
	Dim Result = Ocr.Read(Input)
	' Retrieve all recognized text from the result
	Dim AllText = Result.Text
	' Output the text or use it in further processing
	Console.WriteLine(AllText)
End Using
$vbLabelText   $csharpLabel

ทำไมตองเลอก IronOCR

IronOCR เปนไลบรารซอฟตแวร. NET ทตดตงงายสมบรณและมเอกสารอยางด

เลอก IronOCR เพอใหได ความแมนยำ 99.8% + OCR โดยไมตองใชบรการเวบภายนอกคาธรรมเนยมตอเนองหรอสงเอกสารทเปนความลบทางอนเทอรเนต

ทำไมนกพฒนา C#ถงเลอก IronOCR กบ Vanilla Tesseract:

  • ตดตงเปน DLL เดยวหรอ NuGet
  • รวมถงเครองยนต Tesseract 5, 4 และ 3 นอกกรอบ
  • ความแมนยำ 99.8% เหนอกวา Tesseract ปกตอยางเหนไดชด
  • ความเรวทเหนไดชดและ MultiThreading
  • รองรบ MVC, WebApp, Desktop, Console & Server Application
  • ไมมรหส Exes หรอ C ++ ทจะใชงานได
  • รองรบ PDF OCR เตมรปแบบ
  • ในการดำเนนการ OCR เกอบทกไฟลรปภาพหรอ PDF
  • รองรบ.NET Core, Standard และ FrameWork เตมรปแบบ
  • ปรบใชบน Windows, Mac, Linux, Azure, Docker, Lambda, AWS
  • อานบารโคดและรหส QR
  • สงออก OCR เปน XHTML
  • สงออก OCR ไปยงเอกสาร PDF ทคนหาได
  • รองรบมลตเธรด
  • ภาษาสากล 126 ภาษาทงหมดจดการผานไฟล NuGet หรอ OcrData
  • แยกรปภาพพกดสถตและแบบอกษร ไมใชแคขอความ
  • สามารถใชเพอแจกจาย Tesseract OCR ใหมภายในแอปพลเคชนเชงพาณชยและทเปนกรรมสทธ

IronOCR จะสองสวางเมอทำงานกบภาพในโลกแหงความเปนจรงและเอกสารทไมสมบรณเชนภาพถายหรอการสแกนทมความละเอยดตำซงอาจมสญญาณรบกวนดจทลหรอความไมสมบรณ

ไลบราร OCR ฟร อน ๆ สำหรบแพลตฟอรม. NET เชน. net tesseract API และบรการเวบอน ๆ จะทำงานไดไมดนกในกรณการใชงานจรงเหลาน

OCR พรอม Tesseract 5 - เรมการเขารหสใน C #

ตวอยางโคดดานลางแสดงใหเหนวาการอานขอความจากรปภาพนนงายเพยงใดโดยใช C#หรอ VB .NET

หนงในสายการบน

// Reading text from an image using default settings
string Text = new IronTesseract().Read(@"img\Screenshot.png").Text;
Console.WriteLine(Text);
// Reading text from an image using default settings
string Text = new IronTesseract().Read(@"img\Screenshot.png").Text;
Console.WriteLine(Text);
' Reading text from an image using default settings
Dim Text As String = (New IronTesseract()).Read("img\Screenshot.png").Text
Console.WriteLine(Text)
$vbLabelText   $csharpLabel

Hello World ทกำหนดคาได

// PM> Install-Package IronOCR.Languages.Thai
using IronOcr;

// Initialize IronTesseract for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Process an image with IronOCR
using (var Input = new OcrInput())
{
    // Add an image file to the OCR input
    Input.AddImage("images/sample.jpeg");
    // You can add more images for multi-page OCR

    var Result = Ocr.Read(Input);
    // Print the recognized text to the console
    Console.WriteLine(Result.Text);
}
// PM> Install-Package IronOCR.Languages.Thai
using IronOcr;

// Initialize IronTesseract for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Process an image with IronOCR
using (var Input = new OcrInput())
{
    // Add an image file to the OCR input
    Input.AddImage("images/sample.jpeg");
    // You can add more images for multi-page OCR

    var Result = Ocr.Read(Input);
    // Print the recognized text to the console
    Console.WriteLine(Result.Text);
}
' PM> Install-Package IronOCR.Languages.Thai
Imports IronOcr

' Initialize IronTesseract for OCR
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Process an image with IronOCR
Using Input = New OcrInput()
	' Add an image file to the OCR input
	Input.AddImage("images/sample.jpeg")
	' You can add more images for multi-page OCR

	Dim Result = Ocr.Read(Input)
	' Print the recognized text to the console
	Console.WriteLine(Result.Text)
End Using
$vbLabelText   $csharpLabel

C#PDF OCR

วธเดยวกนนสามารถใชในการแยกขอความจากเอกสาร PDF ใด ๆ

using IronOcr;

// Initialize the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Open the PDF document
using (var input = new OcrInput())
{
    input.AddPdf("example.pdf", "password");
    // Optionally select specific pages to OCR

    // Perform the OCR scan
    var Result = Ocr.Read(input);

    // Output the recognized text and page count
    Console.WriteLine(Result.Text);
    Console.WriteLine($"{Result.Pages.Count()} Pages");
    // 1 page for every page in the PDF
}
using IronOcr;

// Initialize the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Open the PDF document
using (var input = new OcrInput())
{
    input.AddPdf("example.pdf", "password");
    // Optionally select specific pages to OCR

    // Perform the OCR scan
    var Result = Ocr.Read(input);

    // Output the recognized text and page count
    Console.WriteLine(Result.Text);
    Console.WriteLine($"{Result.Pages.Count()} Pages");
    // 1 page for every page in the PDF
}
Imports IronOcr

' Initialize the OCR engine
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Open the PDF document
Using input = New OcrInput()
	input.AddPdf("example.pdf", "password")
	' Optionally select specific pages to OCR

	' Perform the OCR scan
	Dim Result = Ocr.Read(input)

	' Output the recognized text and page count
	Console.WriteLine(Result.Text)
	Console.WriteLine($"{Result.Pages.Count()} Pages")
	' 1 page for every page in the PDF
End Using
$vbLabelText   $csharpLabel

OCR สำหรบ MultiPage TIFF

OCR อานรปแบบไฟล TIFF รวมถงเอกสารหลายหนา TIFF ยงสามารถแปลงเปนไฟล PDF ไดโดยตรงพรอมขอความทคนหาได

using IronOcr;

// Set up the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Use an input source with multiple frames
using (var Input = new OcrInput())
{
    // Add a multi-frame TIFF file to the input
    input.AddMultiFrameTiff("multi-frame.tiff");

    // Perform the OCR scan
    var Result = Ocr.Read(Input);

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

// Set up the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Use an input source with multiple frames
using (var Input = new OcrInput())
{
    // Add a multi-frame TIFF file to the input
    input.AddMultiFrameTiff("multi-frame.tiff");

    // Perform the OCR scan
    var Result = Ocr.Read(Input);

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

' Set up the OCR engine
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Use an input source with multiple frames
Using Input = New OcrInput()
	' Add a multi-frame TIFF file to the input
	input.AddMultiFrameTiff("multi-frame.tiff")

	' Perform the OCR scan
	Dim Result = Ocr.Read(Input)

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

บารโคดและ QR

คณลกษณะเฉพาะของ IronOCR คอสามารถอานบารโคดและรหส QR จากเอกสารในขณะทกำลงสแกนหาขอความ อนสแตนซของ OcrResult.OcrBarcode Class จะใหขอมลโดยละเอยดแกนกพฒนาเกยวกบบารโคดทสแกนแตละอน

using IronOcr;

// Initialize the OCR engine with barcode reading
var Ocr = new IronTesseract();
Ocr.Configuration.ReadBarCodes = true;

// Provide the input image containing barcodes
using (var input = new OcrInput())
{
    // Add an image file with barcodes to the input
    input.AddImage("img/Barcode.png");

    // Execute the OCR process
    var Result = Ocr.Read(input);

    // Iterate over all detected barcodes and print their values
    foreach (var Barcode in Result.Barcodes)
    {
        Console.WriteLine(Barcode.Value);
        // Additional properties like type and location are available
    }
}
using IronOcr;

// Initialize the OCR engine with barcode reading
var Ocr = new IronTesseract();
Ocr.Configuration.ReadBarCodes = true;

// Provide the input image containing barcodes
using (var input = new OcrInput())
{
    // Add an image file with barcodes to the input
    input.AddImage("img/Barcode.png");

    // Execute the OCR process
    var Result = Ocr.Read(input);

    // Iterate over all detected barcodes and print their values
    foreach (var Barcode in Result.Barcodes)
    {
        Console.WriteLine(Barcode.Value);
        // Additional properties like type and location are available
    }
}
Imports IronOcr

' Initialize the OCR engine with barcode reading
Private Ocr = New IronTesseract()
Ocr.Configuration.ReadBarCodes = True

' Provide the input image containing barcodes
Using input = New OcrInput()
	' Add an image file with barcodes to the input
	input.AddImage("img/Barcode.png")

	' Execute the OCR process
	Dim Result = Ocr.Read(input)

	' Iterate over all detected barcodes and print their values
	For Each Barcode In Result.Barcodes
		Console.WriteLine(Barcode.Value)
		' Additional properties like type and location are available
	Next Barcode
End Using
$vbLabelText   $csharpLabel

OCR ในพนทเฉพาะของภาพ

วธการสแกนและการอานทงหมดของ IronOCR ใหความสามารถในการระบวาสวนใดของหนาหรอหนาทเราตองการอานขอความ สงนมประโยชนมากเมอเราดรปแบบมาตรฐานและสามารถประหยดเวลาไดมากและปรบปรงประสทธภาพ

ในการใชพนทครอบตดเราจะตองเพมการอางองระบบไปยง System.Drawing เพอใหเราสามารถใชวตถ System.Drawing.Rectangle

using IronOcr;
using System.Drawing; // Add a reference for System.Drawing

// Set up the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Specify a specific region of the image for OCR
using (var Input = new OcrInput())
{
    var ContentArea = new System.Drawing.Rectangle
    {
        X = 215,
        Y = 1250,
        Height = 280,
        Width = 1335
    };
    // Dimensions are in pixels

    // Add the specific content area of the input image
    Input.Add("document.png", ContentArea);

    // Perform OCR on the specified content area
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
using IronOcr;
using System.Drawing; // Add a reference for System.Drawing

// Set up the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Specify a specific region of the image for OCR
using (var Input = new OcrInput())
{
    var ContentArea = new System.Drawing.Rectangle
    {
        X = 215,
        Y = 1250,
        Height = 280,
        Width = 1335
    };
    // Dimensions are in pixels

    // Add the specific content area of the input image
    Input.Add("document.png", ContentArea);

    // Perform OCR on the specified content area
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Imports IronOcr
Imports System.Drawing ' Add a reference for System.Drawing

' Set up the OCR engine
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Specify a specific region of the image for OCR
Using Input = New OcrInput()
	Dim ContentArea = New System.Drawing.Rectangle With {
		.X = 215,
		.Y = 1250,
		.Height = 280,
		.Width = 1335
	}
	' Dimensions are in pixels

	' Add the specific content area of the input image
	Input.Add("document.png", ContentArea)

	' Perform OCR on the specified content area
	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
$vbLabelText   $csharpLabel

OCR สำหรบการสแกนคณภาพตำ

คลาส OcrInput IronOCR สามารถแกไขการสแกนท Tesseract ปกตไมสามารถอานได

using IronOcr;

// Set up the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Provide a low-quality image input for OCR
using (var Input = new OcrInput(@"img\Potter.LowQuality.tiff"))
{
    // Enhance image quality
    Input.DeNoise(); // Remove digital noise
    Input.Deskew(); // Correct image alignment

    // Execute the OCR process
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
using IronOcr;

// Set up the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Provide a low-quality image input for OCR
using (var Input = new OcrInput(@"img\Potter.LowQuality.tiff"))
{
    // Enhance image quality
    Input.DeNoise(); // Remove digital noise
    Input.Deskew(); // Correct image alignment

    // Execute the OCR process
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Imports IronOcr

' Set up the OCR engine
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Provide a low-quality image input for OCR
Using Input = New OcrInput("img\Potter.LowQuality.tiff")
	' Enhance image quality
	Input.DeNoise() ' Remove digital noise
	Input.Deskew() ' Correct image alignment

	' Execute the OCR process
	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
$vbLabelText   $csharpLabel

สงออกผลลพธ OCR เปน PDF ทคนหาได

รปภาพเปน PDF พรอมสตรงขอความทคดลอกได สามารถจดทำดชนโดยเครองมอคนหาและฐานขอมล

using IronOcr;

// Initialize IronTesseract for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Input multiple images to create a searchable PDF
using (var Input = new OcrInput())
{
    Input.Title = "Quarterly Report"; // Set PDF title
    Input.AddImage("image1.jpeg");
    Input.AddImage("image2.png");
    Input.AddImage("image3.gif");

    // Perform OCR on input images
    var Result = Ocr.Read(input);

    // Save OCR results as a searchable PDF file
    Result.SaveAsSearchablePdf("searchable.pdf");
}
using IronOcr;

// Initialize IronTesseract for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Input multiple images to create a searchable PDF
using (var Input = new OcrInput())
{
    Input.Title = "Quarterly Report"; // Set PDF title
    Input.AddImage("image1.jpeg");
    Input.AddImage("image2.png");
    Input.AddImage("image3.gif");

    // Perform OCR on input images
    var Result = Ocr.Read(input);

    // Save OCR results as a searchable PDF file
    Result.SaveAsSearchablePdf("searchable.pdf");
}
Imports IronOcr

' Initialize IronTesseract for OCR
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Input multiple images to create a searchable PDF
Using Input = New OcrInput()
	Input.Title = "Quarterly Report" ' Set PDF title
	Input.AddImage("image1.jpeg")
	Input.AddImage("image2.png")
	Input.AddImage("image3.gif")

	' Perform OCR on input images
	Dim Result = Ocr.Read(input)

	' Save OCR results as a searchable PDF file
	Result.SaveAsSearchablePdf("searchable.pdf")
End Using
$vbLabelText   $csharpLabel

TIFF เพอการแปลง PDF ทคนหาได

แปลงเอกสาร TIFF (หรอกลมไฟลภาพใด ๆ ) ใหเปน PDF ทคนหาไดโดยตรงซงสามารถสรางดชนไดโดยอนทราเนตเวบไซตและเครองมอคนหาของ Google

using IronOcr;

// Set up the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Add a multi-frame TIFF for conversion
using (var Input = new OcrInput())
{
    input.AddMultiFrameTiff("example.tiff");

    // Execute the OCR process and save as a searchable PDF
    var Result = Ocr.Read(input).SaveAsSearchablePdf("searchable.pdf");
}
using IronOcr;

// Set up the OCR engine
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Add a multi-frame TIFF for conversion
using (var Input = new OcrInput())
{
    input.AddMultiFrameTiff("example.tiff");

    // Execute the OCR process and save as a searchable PDF
    var Result = Ocr.Read(input).SaveAsSearchablePdf("searchable.pdf");
}
Imports IronOcr

' Set up the OCR engine
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Add a multi-frame TIFF for conversion
Using Input = New OcrInput()
	input.AddMultiFrameTiff("example.tiff")

	' Execute the OCR process and save as a searchable PDF
	Dim Result = Ocr.Read(input).SaveAsSearchablePdf("searchable.pdf")
End Using
$vbLabelText   $csharpLabel

สงออกผลลพธ OCR เปน HTML

การแปลง OCR Image เปน XHTML

using IronOcr;

// Initialize IronTesseract for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Perform OCR on an image and export results as XHTML
using (var Input = new OcrInput())
{
    Input.Title = "Html Title"; // Set HTML title
    Input.AddImage("image1.jpeg");

    // Execute the OCR process
    var Result = Ocr.Read(input);

    // Save results in HTML format
    Result.SaveAsHocrFile("results.html");
}
using IronOcr;

// Initialize IronTesseract for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Perform OCR on an image and export results as XHTML
using (var Input = new OcrInput())
{
    Input.Title = "Html Title"; // Set HTML title
    Input.AddImage("image1.jpeg");

    // Execute the OCR process
    var Result = Ocr.Read(input);

    // Save results in HTML format
    Result.SaveAsHocrFile("results.html");
}
Imports IronOcr

' Initialize IronTesseract for OCR
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Perform OCR on an image and export results as XHTML
Using Input = New OcrInput()
	Input.Title = "Html Title" ' Set HTML title
	Input.AddImage("image1.jpeg")

	' Execute the OCR process
	Dim Result = Ocr.Read(input)

	' Save results in HTML format
	Result.SaveAsHocrFile("results.html")
End Using
$vbLabelText   $csharpLabel

ตวกรองการปรบปรงภาพ OCR

IronOCR มตวกรองเฉพาะสำหรบ OcrInput เพอปรบปรงประสทธภาพของ OCR

ตวอยางรหสการปรบปรงภาพ

ทำใหภาพอนพต OCR มคณภาพสงขนเพอใหไดผลลพธ OCR ทดขนและเรวขน

using IronOcr;

// Initialize IronTesseract for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Enhance and process a low-quality image
using (var Input = new OcrInput(@"LowQuality.jpeg"))
{
    Input.DeNoise(); // Remove digital noise
    Input.Deskew(); // Correct image alignment

    // Execute the OCR process
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
using IronOcr;

// Initialize IronTesseract for OCR
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;

// Enhance and process a low-quality image
using (var Input = new OcrInput(@"LowQuality.jpeg"))
{
    Input.DeNoise(); // Remove digital noise
    Input.Deskew(); // Correct image alignment

    // Execute the OCR process
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Imports IronOcr

' Initialize IronTesseract for OCR
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai

' Enhance and process a low-quality image
Using Input = New OcrInput("LowQuality.jpeg")
	Input.DeNoise() ' Remove digital noise
	Input.Deskew() ' Correct image alignment

	' Execute the OCR process
	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
$vbLabelText   $csharpLabel

รายการตวกรองภาพ OCR

ตวกรองอนพตเพอเพมประสทธภาพ OCR ซงตดตงไวใน IronOCR ไดแก :

  • OcrInput.Rotate (องศาสองเทา) - หมนภาพตามจำนวนองศาตามเขมนาฬกา สำหรบทวนเขมนาฬกาใหใชจำนวนลบ
  • OcrInput.Binarize () - ฟลเตอรภาพนจะเปลยนทกพกเซลเปนสดำหรอสขาวโดยไมมพนกลาง อาจปรบปรงประสทธภาพของ OCR กรณทมความคมชดของขอความกบพนหลงตำมาก
  • OcrInput ToGrayScale () - ฟลเตอรภาพนจะเปลยนทกพกเซลใหอยในเฉดสเทา ไมนาจะปรบปรงความแมนยำของ OCR แตอาจเพมความเรวได
  • OcrInput.Contrast () - เพมคอนทราสตโดยอตโนมต ตวกรองนมกจะปรบปรงความเรวและความแมนยำของ OCR ในการสแกนคอนทราสตตำ
  • OcrInput.DeNoise () - ลบสญญาณรบกวนดจตอล ควรใชตวกรองนเฉพาะในกรณทคาดวาจะมเสยงดง
  • OcrInput.Invert () - สลบสทกส เชนขาวกลายเปนดำ: ดำกลายเปนขาว
  • OcrInput.Dilate () - สณฐานวทยาขนสง การขยาย เพมพกเซลใหกบขอบเขตของวตถในภาพ ตรงขามเซาะกราว
  • OcrInput.Erode () - สณฐานวทยาขนสง การกดเซาะ จะลบพกเซลบนขอบเขตวตถตรงขามกบ Dilate
  • OcrInput.Deskew () - หมนภาพเพอใหอยในตำแหนงทถกตองและตงฉากกน สงนมประโยชนมากสำหรบ OCR เนองจากความอดทนของ Tesseract สำหรบการสแกนทเอยงอาจตำถง 5 องศา
  • OcrInput.DeepCleanBackgroundNoise () - การกำจดเสยงรบกวนรอบขางหนก ใชตวกรองนในกรณททราบเสยงพนหลงของเอกสารมากเทานนเนองจากตวกรองนจะเสยงตอการลดความแมนยำของ OCR ของเอกสารทสะอาดและมราคาแพงมากของ CPU
  • OcrInput.EnhanceResolution - เพมความละเอยดของภาพคณภาพตำ ไมจำเปนตองใชตวกรองนบอยครงเนองจาก OcrInput.MinimumDPI และ OcrInput.TargetDPI จะตรวจจบและแกไขอนพตทมความละเอยดตำโดยอตโนมต

ทำความสะอาดพนหลง นคอการตงคาทคอนขางใชเวลานาน อยางไรกตามชวยใหไลบรารสามารถลางสญญาณรบกวนดจทลรอยยนของกระดาษและความไมสมบรณอน ๆ ภายในภาพดจทลโดยอตโนมตซงจะทำใหไลบราร OCR อนอานไมได

EnhanceContrast คอการตงคาททำให IronOCR เพมความคมชดของขอความกบพนหลงของภาพโดยอตโนมตเพมความแมนยำของ OCR และโดยทวไปจะเพมประสทธภาพและความเรวของ OCR

EnhanceResolution คอการตงคาทจะตรวจจบภาพทมความละเอยดตำโดยอตโนมต (ซงมความละเอยดตำกวา 275 dpi) และเพมขนาดภาพโดยอตโนมตจากนนเพมความคมชดของขอความทงหมดเพอใหสามารถอานไดอยางสมบรณแบบโดยไลบราร OCR แมวาการดำเนนการนจะใชเวลานาน แตโดยทวไปแลวจะชวยลดเวลาโดยรวมสำหรบการดำเนนการ OCR บนรปภาพ

Language IronOCR รองรบชดภาษาสากล 22 ชดและสามารถใชการตงคาภาษาเพอเลอกหนงหรอหลายภาษาทจะใชสำหรบการดำเนนการ OCR

Strategy IronOCR รองรบสองกลยทธ เราอาจเลอกทจะสแกนเอกสารทรวดเรวและแมนยำนอยกวาหรอใชกลยทธขนสงซงใชแบบจำลองปญญาประดษฐเพอปรบปรงความถกตองของขอความ OCR โดยอตโนมตโดยดความสมพนธทางสถตของคำทมตอกนในประโยค .

ColorSpace คอการตงคาทเราสามารถเลอกให OCR เปนโทนสเทาหรอส โดยทวไปสเทาเปนตวเลอกทดทสด อยางไรกตามบางครงเมอมขอความหรอพนหลงทมสคลายกน แตมสตางกนมากพนทสเตมจะใหผลลพธทดกวา

DetectWhiteTextOnDarkBackgrounds โดยทวไปแลวไลบราร OCR ทงหมดคาดวาจะเหนขอความสดำบนพนหลงสขาว การตงคานชวยให IronOCR ตรวจจบเชงลบโดยอตโนมตหรอหนามดทมขอความสขาวและอานได

InputImageType การตงคานชวยใหนกพฒนาสามารถแนะนำไลบราร OCR ไดวากำลงดเอกสารฉบบเตมหรอตวอยางขอมลเชนภาพหนาจอ

RotateAndStraighten เปนการตงคาขนสงทชวยให IronOCR มความสามารถพเศษในการอานเอกสารทไมเพยง แตหมนได แตอาจมมมมองเชนภาพถายของเอกสารขอความ

ReadBarcodes เปนคณสมบตทมประโยชนซงชวยให IronOCR สามารถอานบารโคดและรหส QR บนหนาไดโดยอตโนมตในขณะทอานขอความโดยไมตองเพมภาระเวลาเพมเตม

ความลกของส การตงคานกำหนดจำนวนบตตอพกเซลทไลบราร OCR จะใชเพอกำหนดความลกของส ความลกของสทสงขนอาจเพมคณภาพของ OCR แตจะเพมเวลาในการดำเนนการ OCR ใหเสรจสมบรณดวย

126 ชดภาษา

IronOCR รองรบ ภาษาสากล 126 ภาษา ผานชดภาษาซงแจกจายเปน DLL ซงสามารถ ดาวนโหลดไดจากเวบไซตน หรอจาก NuGet Package Manager

ภาษาตางๆ ไดแก เยอรมนฝรงเศสองกฤษจนญปนและอน ๆ อกมากมาย มชดภาษาผเชยวชาญสำหรบหนงสอเดนทาง MRZ, การตรวจสอบ MICR, ขอมลทางการเงน, ปายทะเบยนและอน ๆ อกมากมาย คณยงสามารถใชไฟล ".traineddata" ของ tesseract รวมทงไฟลทคณสรางขนเอง

ตวอยางภาษา

การใชภาษา OCR อน ๆ

// using IronOcr;
// PM> Install-Package IronOcr.Languages.Arabic

using IronOcr;

// Initialize the OCR engine for Arabic language
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Arabic;

// Provide the input image containing Arabic text
using (var input = new OcrInput())
{
    input.AddImage("img/arabic.gif");

    // Optional: Enhance image if necessary
    // OCR even for low-quality input
    var Result = Ocr.Read(input);

    // Save results as a text file since Console may not display Arabic text correctly
    Result.SaveAsTextFile("arabic.txt");
}
// using IronOcr;
// PM> Install-Package IronOcr.Languages.Arabic

using IronOcr;

// Initialize the OCR engine for Arabic language
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Arabic;

// Provide the input image containing Arabic text
using (var input = new OcrInput())
{
    input.AddImage("img/arabic.gif");

    // Optional: Enhance image if necessary
    // OCR even for low-quality input
    var Result = Ocr.Read(input);

    // Save results as a text file since Console may not display Arabic text correctly
    Result.SaveAsTextFile("arabic.txt");
}
' using IronOcr;
' PM> Install-Package IronOcr.Languages.Arabic

Imports IronOcr

' Initialize the OCR engine for Arabic language
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Arabic

' Provide the input image containing Arabic text
Using input = New OcrInput()
	input.AddImage("img/arabic.gif")

	' Optional: Enhance image if necessary
	' OCR even for low-quality input
	Dim Result = Ocr.Read(input)

	' Save results as a text file since Console may not display Arabic text correctly
	Result.SaveAsTextFile("arabic.txt")
End Using
$vbLabelText   $csharpLabel

ตวอยางหลายภาษา

นอกจากนยงสามารถ OCR โดยใชหลายภาษาในเวลาเดยวกน สงนสามารถชวยรบขอมลเมตาและ URL ภาษาองกฤษในเอกสาร Unicode ไดจรงๆ

// using IronOcr;
// PM> Install-Package IronOcr.Languages.ChineseSimplified

using IronOcr;

// Initialize the OCR engine with multiple languages
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.ChineseSimplified;
Ocr.AddSecondaryLanguage(OcrLanguage.Thai); // Additional language

// Input a multi-language document
using (var input = new OcrInput())
{
    input.Add("multi-language.pdf");

    // Perform OCR with multiple languages
    var Result = Ocr.Read(input);

    // Save results in a text file
    Result.SaveAsTextFile("results.txt");
}
// using IronOcr;
// PM> Install-Package IronOcr.Languages.ChineseSimplified

using IronOcr;

// Initialize the OCR engine with multiple languages
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.ChineseSimplified;
Ocr.AddSecondaryLanguage(OcrLanguage.Thai); // Additional language

// Input a multi-language document
using (var input = new OcrInput())
{
    input.Add("multi-language.pdf");

    // Perform OCR with multiple languages
    var Result = Ocr.Read(input);

    // Save results in a text file
    Result.SaveAsTextFile("results.txt");
}
' using IronOcr;
' PM> Install-Package IronOcr.Languages.ChineseSimplified

Imports IronOcr

' Initialize the OCR engine with multiple languages
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.ChineseSimplified
Ocr.AddSecondaryLanguage(OcrLanguage.Thai) ' Additional language

' Input a multi-language document
Using input = New OcrInput()
	input.Add("multi-language.pdf")

	' Perform OCR with multiple languages
	Dim Result = Ocr.Read(input)

	' Save results in a text file
	Result.SaveAsTextFile("results.txt")
End Using
$vbLabelText   $csharpLabel

วตถผลลพธ OCR โดยละเอยด

IronOCR สงคนออบเจกตผลลพธ OCR สำหรบการดำเนนการ OCR แตละครง โดยทวไปนกพฒนาจะใชคณสมบตขอความของวตถนเพอรบขอความทสแกนจากรปภาพเทานน อยางไรกตามผลลพธของ OCR DOM นนกาวหนากวานมาก

using IronOcr;
using System.Drawing; // Add a reference for System.Drawing

// Initialize the OCR engine with necessary configurations
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm;
Ocr.Configuration.ReadBarCodes = true; // Enable barcode reading

// Perform OCR on the input image
using (var Input = new OcrInput(@"images\sample.tiff"))
{
    OcrResult Result = Ocr.Read(Input);

    // Access detailed OCR results
    var Pages = Result.Pages;
    var Words = Pages[0].Words;
    var Barcodes = Result.Barcodes;

    // Explore here to find the rich detailed API for:
    // - Pages, Blocks, Paragraphs, Lines, Words, Characters
    // - Image exports, Font coordinates, statistical data
}
using IronOcr;
using System.Drawing; // Add a reference for System.Drawing

// Initialize the OCR engine with necessary configurations
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Thai;
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm;
Ocr.Configuration.ReadBarCodes = true; // Enable barcode reading

// Perform OCR on the input image
using (var Input = new OcrInput(@"images\sample.tiff"))
{
    OcrResult Result = Ocr.Read(Input);

    // Access detailed OCR results
    var Pages = Result.Pages;
    var Words = Pages[0].Words;
    var Barcodes = Result.Barcodes;

    // Explore here to find the rich detailed API for:
    // - Pages, Blocks, Paragraphs, Lines, Words, Characters
    // - Image exports, Font coordinates, statistical data
}
Imports IronOcr
Imports System.Drawing ' Add a reference for System.Drawing

' Initialize the OCR engine with necessary configurations
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Thai
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm
Ocr.Configuration.ReadBarCodes = True ' Enable barcode reading

' Perform OCR on the input image
Using Input = New OcrInput("images\sample.tiff")
	Dim Result As OcrResult = Ocr.Read(Input)

	' Access detailed OCR results
	Dim Pages = Result.Pages
	Dim Words = Pages(0).Words
	Dim Barcodes = Result.Barcodes

	' Explore here to find the rich detailed API for:
	' - Pages, Blocks, Paragraphs, Lines, Words, Characters
	' - Image exports, Font coordinates, statistical data
End Using
$vbLabelText   $csharpLabel

ประสทธภาพ

IronOCR ทำงานนอกกรอบโดยไมจำเปนตองปรบแตงประสทธภาพหรอปรบเปลยนภาพอนพตมากนก

Speed is Blazing: IronOcr.2020 + เรวขนสงสด 10 เทาและทำใหเกดขอผดพลาดนอยกวารนกอนหนาถง 250%

เรยนรเพมเตม

หากตองการเรยนรเพมเตมเกยวกบ OCR ในภาษา C #, VB, F # หรอภาษา. NET อน ๆ โปรด อานบทแนะนำชมชนของเรา ซงใหตวอยางโลกแหงความเปนจรงเกยวกบวธการใชงาน IronOCR และอาจแสดงความแตกตางของวธการใชประโยชนสงสดจาก หองสมดน

นอกจากนยงม การอางองออบเจกต แบบเตม สำหรบนกพฒนา. NET