特定のドキュメントを読む方法

This article was translated from English: Does it need improvement?
Translated
View the article in English

によって チャクニット・ビン

標準テキスト文書、ナンバープレート、パスポート、写真などの特定の文書を正確に読み取ることは、一般的な単一の方法では非常に困難です。 これらの課題は、各文書タイプの多様な形式、レイアウト、内容、および画像の品質、歪み、専門的な内容の変動から生じます。 さらに、文書の種類が広がると、コンテキストの理解を達成し、パフォーマンスと効率のバランスを取ることがますます複雑になります。

IronOCRは、標準のテキストドキュメント、ナンバープレート、パスポート、および写真などの特定のドキュメントに対して、最適な精度とパフォーマンスを実現するための特定のOCR方法を導入します。


OCR 用 C# NuGet ライブラリ

でインストール NuGet

Install-Package IronOcr
または
Java PDF JAR(ジャバPDF JAR)

ダウンロード DLL (ディーエルエル)

DLLをダウンロード

プロジェクトに手動でインストールする

OCR 用 C# NuGet ライブラリ

でインストール NuGet

Install-Package IronOcr
または
Java PDF JAR(ジャバPDF JAR)

ダウンロード DLL (ディーエルエル)

DLLをダウンロード

プロジェクトに手動でインストールする

今日からプロジェクトでIronPDFを使い始めましょう。無料のトライアルをお試しください。

最初のステップ:
green arrow pointer

チェックアウト IronOCR オン Nuget 迅速なインストールと展開のために。8百万以上のダウンロード数により、OCRをC#で変革しています。

OCR 用 C# NuGet ライブラリ nuget.org/packages/IronOcr/
Install-Package IronOcr

インストールを検討してください IronOCR DLL 直接。ダウンロードして、プロジェクトまたはGACの形式で手動でインストールしてください。 IronOcr.zip

プロジェクトに手動でインストールする

DLLをダウンロード

パッケージについて

以下の内容を日本語に翻訳します:

メソッド ReadLicensePlateReadPassportReadPhoto、および ReadScreenShot は、基本のIronOCRパッケージに対する拡張メソッドであり、必要となる IronOcr.Extensions.AdvancedScan インストールされるべきパッケージ。 現在、この拡張機能はWindowsでのみ利用可能です。

以下の内容を日本語に翻訳してください:

メソッドは、ブラックリストやホワイトリストなどのOCRエンジン構成で動作します。中国語、日本語、韓国語、ラテンアルファベットを含む複数の言語が、ReadPassportメソッドを除くすべてのメソッドでサポートされています。 各言語には追加の言語パッケージが必要であることにご注意ください。 IronOCR.Languages.

高度なスキャンを .NET Framework で使用するには、プロジェクトを x64アーキテクチャで実行する必要があります。 プロジェクトの設定に移動し、「32ビットを優先」のオプションのチェックを外してください。 次のトラブルシューティングガイドで詳細を学びましょう: .NET Frameworkでの高度なスキャン."

ドキュメント読み取り例

ReadDocument メソッドは、テキストが多く含まれているスキャン文書や紙の文書の写真に特化した堅牢な文書読み取りメソッドです。 PageSegmentationMode設定は、異なるレイアウトのテキストドキュメントを読み取る際に非常に重要です。 たとえば、SingleBlock型やSparseText型は、テーブルのレイアウトから多くの情報を取得することができます。 これはSingleBlockがテキストがブロックとして保持されると仮定するのに対し、SparseTextがテキストが文書全体に散在していると仮定するためです。

:path=/static-assets/ocr/content-code-examples/how-to/read-specific-document-document.cs
using IronOcr;
using System;

// Instantiate OCR engine
var ocr = new IronTesseract();

// Configure OCR engine
ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.SingleBlock;

using var input = new OcrInput();

input.LoadPdf("Five.pdf");

// Perform OCR
OcrResult result = ocr.ReadDocument(input);

Console.WriteLine(result.Text);
Imports IronOcr
Imports System

' Instantiate OCR engine
Private ocr = New IronTesseract()

' Configure OCR engine
ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.SingleBlock

Dim input = New OcrInput()

input.LoadPdf("Five.pdf")

' Perform OCR
Dim result As OcrResult = ocr.ReadDocument(input)

Console.WriteLine(result.Text)
VB   C#

以下のメソッドは、ベースのIronOCRパッケージへの拡張メソッドであり、次のものが必要です。 IronOcr.Extensions.AdvancedScan インストールされるべきパッケージ。 現在、この拡張機能はWindowsでのみ利用可能です。

ナンバープレートを読む例

ReadLicensePlateメソッドは、写真からナンバープレートを読み取るために最適化されています。 このメソッドから返される特別な情報は、Licenseplate プロパティであり、提供されたドキュメント内のナンバープレートの位置情報を含みます。

:path=/static-assets/ocr/content-code-examples/how-to/read-specific-document-license-plate.cs
using IronOcr;
using IronSoftware.Drawing;
using System;

// Instantiate OCR engine
var ocr = new IronTesseract();

using var inputLicensePlate = new OcrInput();

inputLicensePlate.LoadImage("LicensePlate.jpeg");

// Perform OCR
OcrLicensePlateResult result = ocr.ReadLicensePlate(inputLicensePlate);

// Retrieve license plate coordinates
Rectangle rectangle = result.Licenseplate;

// Retrieve license plate value
string output = result.Text;
Imports IronOcr
Imports IronSoftware.Drawing
Imports System

' Instantiate OCR engine
Private ocr = New IronTesseract()

Private inputLicensePlate = New OcrInput()

inputLicensePlate.LoadImage("LicensePlate.jpeg")

' Perform OCR
Dim result As OcrLicensePlateResult = ocr.ReadLicensePlate(inputLicensePlate)

' Retrieve license plate coordinates
Dim rectangle As Rectangle = result.Licenseplate

' Retrieve license plate value
Dim output As String = result.Text
VB   C#

パスポートの例を読む

ReadPassportメソッドは最適化されており、機械読み取り領域をスキャンすることによってパスポート写真からパスポート情報を抽出します。 (MRZ) 内容 MRZは、パスポート、IDカード、ビザなどの公式文書に特別に定義されたゾーンです。 MRZには通常、保有者の氏名、生年月日、国籍、書類番号などの重要な個人情報が含まれています。 現在、このメソッドは英語のみサポートしています。

:path=/static-assets/ocr/content-code-examples/how-to/read-specific-document-passport.cs
using IronOcr;
using System;

// Instantiate OCR engine
var ocr = new IronTesseract();

using var inputPassport = new OcrInput();

inputPassport.LoadImage("Passport.jpg");

// Perform OCR
OcrPassportResult result = ocr.ReadPassport(inputPassport);

// Output passport information
Console.WriteLine(result.PassportInfo.GivenNames);
Console.WriteLine(result.PassportInfo.Country);
Console.WriteLine(result.PassportInfo.PassportNumber);
Console.WriteLine(result.PassportInfo.Surname);
Console.WriteLine(result.PassportInfo.DateOfBirth);
Console.WriteLine(result.PassportInfo.DateOfExpiry);
Imports IronOcr
Imports System

' Instantiate OCR engine
Private ocr = New IronTesseract()

Private inputPassport = New OcrInput()

inputPassport.LoadImage("Passport.jpg")

' Perform OCR
Dim result As OcrPassportResult = ocr.ReadPassport(inputPassport)

' Output passport information
Console.WriteLine(result.PassportInfo.GivenNames)
Console.WriteLine(result.PassportInfo.Country)
Console.WriteLine(result.PassportInfo.PassportNumber)
Console.WriteLine(result.PassportInfo.Surname)
Console.WriteLine(result.PassportInfo.DateOfBirth)
Console.WriteLine(result.PassportInfo.DateOfExpiry)
VB   C#

結果

パスポートを読む

ドキュメントにはパスポートの画像のみが含まれるようにしてください。 ヘッダーとフッターのテキストはメソッドを混乱させ、予期しない出力を引き起こす可能性があります。

写真の例を読む

ReadPhoto メソッドは、読みづらいテキストを含む画像を読み取るために最適化されています。 このメソッドはTextRegionsプロパティを返します。このプロパティには、検出されたテキストに関する有用な情報、例えばRegionTextInRegion、およびFrameNumberが含まれます。

:path=/static-assets/ocr/content-code-examples/how-to/read-specific-document-photo.cs
using IronOcr;
using IronSoftware.Drawing;

// Instantiate OCR engine
var ocr = new IronTesseract();

using var inputPhoto = new OcrInput();
inputPhoto.LoadImageFrame("photo.tif", 2);

// Perform OCR
OcrPhotoResult result = ocr.ReadPhoto(inputPhoto);

// index number refer to region order in the page
int number = result.TextRegions[0].FrameNumber;
string textinregion = result.TextRegions[0].TextInRegion;
Rectangle region = result.TextRegions[0].Region;
Imports IronOcr
Imports IronSoftware.Drawing

' Instantiate OCR engine
Private ocr = New IronTesseract()

Private inputPhoto = New OcrInput()
inputPhoto.LoadImageFrame("photo.tif", 2)

' Perform OCR
Dim result As OcrPhotoResult = ocr.ReadPhoto(inputPhoto)

' index number refer to region order in the page
Dim number As Integer = result.TextRegions(0).FrameNumber
Dim textinregion As String = result.TextRegions(0).TextInRegion
Dim region As Rectangle = result.TextRegions(0).Region
VB   C#

スクリーンショットを読み取る例

ReadScreenShot メソッドは、読みづらいテキストを含むスクリーンショットを読み取るように最適化されています。 読み取り写真(ReadPhoto)メソッドと同様に、TextRegionsプロパティも返します。

:path=/static-assets/ocr/content-code-examples/how-to/read-specific-document-screenshot.cs
using IronOcr;
using System;
using System.Linq;

// Instantiate OCR engine
var ocr = new IronTesseract();

using var inputScreenshot = new OcrInput();
inputScreenshot.LoadImage("screenshot.png");

// Perform OCR
OcrPhotoResult result = ocr.ReadScreenShot(inputScreenshot);

// Output screenshoot information
Console.WriteLine(result.Text);
Console.WriteLine(result.TextRegions.First().Region.X);
Console.WriteLine(result.TextRegions.Last().Region.Width);
Console.WriteLine(result.Confidence);
Imports IronOcr
Imports System
Imports System.Linq

' Instantiate OCR engine
Private ocr = New IronTesseract()

Private inputScreenshot = New OcrInput()
inputScreenshot.LoadImage("screenshot.png")

' Perform OCR
Dim result As OcrPhotoResult = ocr.ReadScreenShot(inputScreenshot)

' Output screenshoot information
Console.WriteLine(result.Text)
Console.WriteLine(result.TextRegions.First().Region.X)
Console.WriteLine(result.TextRegions.Last().Region.Width)
Console.WriteLine(result.Confidence)
VB   C#

チャクニット・ビン

ソフトウェアエンジニア

チャクニットは開発者のシャーロック・ホームズです。彼がソフトウェアエンジニアリングの将来性に気付いたのは、楽しみでコーディングチャレンジをしていたときでした。彼のフォーカスはIronXLとIronBarcodeにありますが、すべての製品でお客様を助けることに誇りを持っています。チャクニットは顧客と直接話すことで得た知識を活用して、製品自体のさらなる改善に貢献しています。彼の逸話的なフィードバックは、単なるJiraチケットを超えて、製品開発、ドキュメントおよびマーケティングをサポートし、顧客の全体的な体験を向上させます。オフィスにいないときは、機械学習やコーディングについて学んだり、ハイキングを楽しんだりしています。