How to Read Specialized Documents with C# and IronOCR
標準的なテキスト文書、ナンバープレート、パスポート、写真などの特定の文書を一般的な単一の方法で正確に読み取るのは非常に困難です。 これらの課題は、各ドキュメント タイプの形式、レイアウト、コンテンツの多様性、および画像品質、歪み、特殊なコンテンツのばらつきに起因します。 さらに、ドキュメントの種類が広くなると、コンテキストの理解を実現し、パフォーマンスと効率性のバランスをとることがより複雑になります。
IronOCR は、標準のテキスト ドキュメント、ナンバー プレート、パスポート、写真などの特定のドキュメントに対して OCR を実行し、最適な精度とパフォーマンスを実現するための具体的な方法を導入します。
クイックスタート: 1行でパスポートを読むIronOCRのReadPassportエクステンションを使用して、パスポートの重要な詳細を最小限の設定で抽出します。IronOCRとAdvancedScanをインストールしたと仮定して、コード1行で名前、パスポート番号、国などの構造化された結果データを迅速かつ簡単に得ることができます。
-
1Install IronOCR with NuGet Package Manager
-
2このコード スニペットをコピーして実行します。
var result = new IronTesseract().ReadPassport(new OcrInput().LoadImage("passport.jpg"));C# -
3実際の環境でテストするためにデプロイする
今日プロジェクトで IronOCR を使い始めましょう無料トライアル
最小限のワークフロー(5ステップ)
- ナンバープレート、パスポート、写真を読み取るための C# ライブラリをダウンロードする
- OCRのための画像とPDFドキュメントを準備
- ナンバープレートを読み取るために
ReadLicensePlateメソッドを設定する - パスポートから情報を取得するために
ReadPassportメソッドを設定します - Leverage the
ReadPhotoandReadScreenShotmethods to read images that contain hard-to-read text
パッケージについて
メソッド ReadScreenShot は、基本のIronOCRパッケージへの拡張メソッドであり、IronOcr.Extensions.AdvancedScanパッケージをインストールする必要があります。
これらのメソッドはブラックリストやホワイトリストのようなOCRエンジン構成で動作します。ReadPassportメソッドを除き、複数の言語に対応しています(中国語、日本語、韓国語、ラテンアルファベットを含む)。 各言語には追加の言語パッケージIronOcr.Languagesが必要であることに注意してください。
.NET Framework で詳細スキャンを使用するには、プロジェクトを x64 アーキテクチャで実行する必要があります。 これを実現するには、プロジェクト構成に移動し、"32 ビットを優先"オプションのチェックを外します。 詳細については、次のトラブルシューティング ガイドを参照してください:". NET Framework の高度なスキャン"。
ドキュメントの例を読む
ReadDocument メソッドは、スキャンされた文書や大量のテキストを含む紙文書の写真に特化した強力な文書読み取りメソッドです。 PageSegmentationMode構成は、異なるレイアウトのテキスト ドキュメントを読み取る際に非常に重要です。
たとえば、 SingleBlock型とSparseText型では、テーブル レイアウトから多くの情報を取得できます。 これは、 SingleBlock ではテキストがブロックとして残っていると想定しているのに対し、 SparseText ではテキストがドキュメント全体に散らばっていると想定しているためです。
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)以下のメソッドは基本 IronOCR パッケージの拡張メソッドであり、 IronOcr.Extensions.AdvancedScanパッケージがインストールされている必要があります。
ナンバープレートの読み取り例
ReadLicensePlate メソッドは、写真からのナンバープレートの読み取りに最適化されています。 このメソッドから返される特別な情報はLicenseplateプロパティであり、これには提供されたドキュメント内のナンバー プレートの位置の情報が含まれます。
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パスポートの例を読む
ReadPassport メソッドは、パスポートの写真からパスポート情報を抽出し、機械読み取り可能ゾーン(MRZ)の内容をスキャンするために最適化されています。 MRZ は、パスポート、ID カード、ビザなどの公式文書内で特別に定義されたゾーンです。 MRZ には通常、保有者の名前、生年月日、国籍、文書番号などの重要な個人情報が含まれています。 現在、この方法は英語のみをサポートしています。
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)結果

書類にはパスポートの画像のみが含まれていることを確認してください。 ヘッダーとフッターのテキストによりメソッドが混乱し、予期しない出力が発生する可能性があります。
写真の例を読む
ReadPhoto メソッドは、読みにくいテキストを含む画像の読み取りに最適化されています。 このメソッドはTextRegionsプロパティを返します。このプロパティには、 Region 、 TextInRegion 、 FrameNumberなど、検出されたテキストに関する有用な情報が含まれています。
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].PageNumber;
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).PageNumber
Dim textinregion As String = result.TextRegions(0).TextInRegion
Dim region As Rectangle = result.TextRegions(0).Regionスクリーンショットの例を読む
ReadScreenShot メソッドは、読みにくいテキストを含むスクリーンショットを読み取るために最適化されています。 ReadPhoto メソッドと同様に、 TextRegionsプロパティも返します。
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)よくある質問
C# で OCR を使用してナンバープレートを読むにはどうすればよいですか?
IronOCR が提供する ReadLicensePlate メソッドを使用すると、写真からナンバープレートを正確に読み取ることができます。このメソッドは、ナンバープレートテキストとその位置情報を返します。
パスポート写真から情報を抽出する最良の方法は何ですか?
IronOCR の ReadPassport メソッドは、パスポート写真の機械可読領域(MRZ)をスキャンして、名前、生年月日、文書番号などの重要な情報を抽出することを目的としています。
IronOCR は読みづらいテキストが含まれる写真からテキストを読み取れますか?
はい、IronOCR の ReadPhoto メソッドは、読みづらいテキストのある画像を読むように最適化されており、検出されたテキストとその領域についての詳細データを提供します。
IronOCR を使用してスクリーンショットからテキストを読み取ることは可能ですか?
もちろん、IronOCR の ReadScreenShot メソッドは、スクリーンショットのテキスト処理に特化して最適化されており、詳細なテキスト領域情報を提供します。
複雑なレイアウトのドキュメントで OCR の精度を向上させるにはどうすればよいですか?
複雑なドキュメントレイアウトの OCR 精度を高めるためには、IronOCR の PageSegmentationMode を設定します。SingleBlock や SparseText などのオプションは、表形式のレイアウトからの情報抽出に特に有用です。
IronOCR の高度なスキャン機能が .NET Framework プロジェクトで動作しない場合、どうすればよいですか?
.NET Framework 上の IronOCR の高度なスキャン機能に関する問題を解決するには、プロジェクト設定で「32 ビット優先」オプションのチェックを外して、プロジェクトを x64 アーキテクチャで実行するように設定します。
IronOCR に言語サポートの制約はありますか?
IronOCR は、中国語、日本語、韓国語、ラテンアルファベットを含む複数の言語をサポートしています。ただし、ReadPassport メソッドは現在、英語の文書のみをサポートしています。
IronOCR の高度なスキャン機能を使用するにはどうすればよいですか?
IronOCR の高度なスキャン機能を使用するには、IronOcr.Extensions.AdvancedScan パッケージが必要で、これは Windows でのみ利用可能です。
What precautions should be taken when using the `ReadPassport` method?
When using the `ReadPassport` method, ensure that the image only contains the passport photo to avoid confusion and unexpected output. Any additional text like headers and footers should be excluded.
How can IronOCR be installed to perform document reading in C#?
IronOCR can be installed via the NuGet package manager. Ensure that both IronOCR and IronOcr.Extensions.AdvancedScan are installed to utilize methods for reading specialized document types like license plates and passports.

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。