C#およびVB.NETでOCRを始める
IronOCR は、.NET プラットフォーム ソフトウェア開発者が画像や PDF ドキュメントからテキストを認識して読み取ることができる C# ソフトウェア ライブラリです。 これは、最も高度なTesseractエンジンを使用した純粋な.NET OCRライブラリです。
インストール
NuGetパッケージマネージャでインストール
Visual StudioまたはコマンドラインでNuGet Package Managerを使用してIronOCRをインストールします。 Visual Studio で、次のコマンドを使用してコンソールに移動します。
- ツール ->
- NuGet パッケージ マネージャー ->
- パッケージマネージャーコンソール
バージョン更新とインストールについて詳しくはNuGet上のIronOCRを確認してください。
さまざまなプラットフォームで利用できる他のIronOCR NuGet パッケージがあります。
- Windows: https://www.nuget.org/packages/IronOcr
- Linux: https://www.nuget.org/packages/IronOcr.Linux
- MacOS: https://www.nuget.org/packages/IronOcr.MacOs
- MacOS (ARM): https://www.nuget.org/packages/IronOcr.MacOs.ARM
Linux および macOS 用の IronOcr.Extensions.AdvancedScan
このパッケージは、LinuxとMacを使用し、IronOCRの高度な機能を利用したいユーザー向けです。
- Linux: https://www.nuget.org/packages/IronOcr.Extensions.AdvancedScan.Linux
- MacOS: https://www.nuget.org/packages/IronOcr.Extensions.AdvancedScan.MacOs
トラブルシューティング
このパッケージの新しいアップデートにより、IronOCR はパッケージ内の OpenCV 依存関係を結合して合理化しますが、現在 OpenCV 依存関係をインポートしている開発者は次のエラーを受け取ります。
The type of namespace name `OpenCvSharp` could not be found(are you missing a using directive or an assembly reference)
OpenCV 名前空間を安全に削除すると、問題は解決されます。
IronOCR .ZIPをダウンロード
代わりに、.ZIP ファイル経由で IronOCR をダウンロードすることもできます。 DLLを直接ダウンロードするにはクリックしてください。 .zip をダウンロードしたら:
.NET Framework 4.0+ のインストール手順:
-
net40フォルダ内のIronOcr.dllをプロジェクトに含めます
-
次にアセンブリ参照を追加します:
- システム構成
- システム.描画
- システム.Web
.NET Standard、.NET Core 2.0+、.NET 5 の手順
-
netstandard2.0フォルダ内のIronOcr.dllをプロジェクトに含めます
-
次に、NuGet パッケージ参照を追加します。
- システム.描画.Common 4.7 以上
IronOCRインストーラーをダウンロードする(Windowsのみ)
別の選択肢として、IronOCRインストーラーをダウンロードし、必要なリソースをインストールします。 このオプションは Windows システム専用であることに注意してください。 インストーラーをダウンロードするにはここをクリックしてください。 .zip をダウンロードしたら:
.NET Framework 4.0+ のインストール手順:
-
net40フォルダ内のIronOcr.dllをプロジェクトに含めます
-
次にアセンブリ参照を追加します:
- システム構成
- システム.描画
- システム.Web
.NET Standard、.NET Core 2.0+、.NET 5 の手順
-
netstandard2.0フォルダ内のIronOcr.dllをプロジェクトに含めます
-
次に、NuGet パッケージ参照を追加します。
- システム.描画.Common 4.7 以上
IronOCRを選ぶ理由
IronOCR は、簡単にインストールでき、完全で、十分に文書化された .NET ソフトウェア ライブラリです。
IronOCR を選択すると、外部 Web サービスを使用したり、継続的な料金を支払ったり、機密文書をインターネット経由で送信したりすることなく、99.8% 以上の OCR 精度を実現できます。
なぜC#開発者が標準のTesseractよりIronOCRを選ぶのか:
- 単一のDLLまたはNuGetとしてインストール
- Tesseract 5、4、および 3 エンジンがすぐに使用できます。
- 精度99.8% は通常の Tesseract を大幅に上回ります。
- 驚異的なスピードとマルチスレッド
- MVC、WebApp、デスクトップ、コンソール、サーバーアプリケーションと互換性があります
- 作業に必要なEXEやC++コードはありません
- 完全なPDF OCRサポート
- ほぼすべての画像ファイルやPDFでOCRを実行
- .NET Core、Standard、Framework の完全サポート
- Windows、Mac、Linux、Azure、Docker、Lambda、AWS にデプロイ可能
- バーコードとQRコードを読み取る
- OCR結果をXHTMLとしてエクスポート
- OCRを検索可能なPDF文書にエクスポート
- マルチスレッドサポート
- 125の国際言語はすべてNuGetまたはOcrDataファイルで管理されます
- 画像、座標、統計、フォントを抽出します。 テキストだけではありません。
- 商用および独自のアプリケーション内で Tesseract OCR を再配布するために使用できます。
IronOCR は、現実世界の画像や写真などの不完全な文書、あるいはデジタル ノイズや不完全さがある可能性のある低解像度のスキャンを処理する場合に威力を発揮します。
.NETプラットフォーム用の他の無料OCRライブラリや他の.NETテッセラクトAPIおよびウェブサービスは、これらの現実の使用事例ではうまく機能しません。
Tesseract 5によるOCR - C#でコーディングを始める
以下のコード サンプルは、C# または VB .NET を使用して画像からテキストを簡単に読み取る方法を示しています。
ワンライナー
string Text = new IronTesseract().Read(@"img\Screenshot.png").Text;Dim Text As String = (New IronTesseract()).Read("img\Screenshot.png").TextDim Text As String = (New IronTesseract()).Read("img\Screenshot.png").Text設定可能なHello World
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
// Add multiple images
input.LoadImage("images/sample.jpeg");
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
// Add multiple images
input.LoadImage("images/sample.jpeg");
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
' Add multiple images
input.LoadImage("images/sample.jpeg")
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
' Add multiple images
input.LoadImage("images/sample.jpeg")
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)C# PDF OCR
同じアプローチを使用して、任意の PDF ドキュメントからテキストを抽出することもできます。
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
// We can also select specific PDF page numbers to OCR
input.LoadPdf("example.pdf", Password: "password");
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);
// 1 page for every page of the PDF
Console.WriteLine($"{result.Pages.Length} Pages");using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
// We can also select specific PDF page numbers to OCR
input.LoadPdf("example.pdf", Password: "password");
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);
// 1 page for every page of the PDF
Console.WriteLine($"{result.Pages.Length} Pages");Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
' We can also select specific PDF page numbers to OCR
input.LoadPdf("example.pdf", Password:= "password")
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)
' 1 page for every page of the PDF
Console.WriteLine($"{result.Pages.Length} Pages")Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
' We can also select specific PDF page numbers to OCR
input.LoadPdf("example.pdf", Password:= "password")
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)
' 1 page for every page of the PDF
Console.WriteLine($"{result.Pages.Length} Pages")マルチページTIFFのOCR
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("multi-frame.tiff", pageindices);
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("multi-frame.tiff", pageindices);
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
Private pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("multi-frame.tiff", pageindices)
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
Private pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("multi-frame.tiff", pageindices)
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)バーコードとQRコード
IronOCRのユニークな機能は、テキストをスキャンしている間にドキュメントからバーコードとQRコードを読み取ることができることです。 OcrResult.OcrBarcodeクラスのインスタンスは開発者に各バーコードスキャンについての詳細情報を提供します。
using IronOcr;
IronTesseract ocr = new IronTesseract();
ocr.Configuration.ReadBarCodes = true;
using OcrInput input = new OcrInput();
input.LoadImage("img/Barcode.png");
OcrResult Result = ocr.Read(input);
foreach (var Barcode in Result.Barcodes)
{
// type and location properties also exposed
Console.WriteLine(Barcode.Value);
}using IronOcr;
IronTesseract ocr = new IronTesseract();
ocr.Configuration.ReadBarCodes = true;
using OcrInput input = new OcrInput();
input.LoadImage("img/Barcode.png");
OcrResult Result = ocr.Read(input);
foreach (var Barcode in Result.Barcodes)
{
// type and location properties also exposed
Console.WriteLine(Barcode.Value);
}Imports IronOcr
Private ocr As New IronTesseract()
ocr.Configuration.ReadBarCodes = True
Using input As New OcrInput()
input.LoadImage("img/Barcode.png")
Dim Result As OcrResult = ocr.Read(input)
For Each Barcode In Result.Barcodes
' type and location properties also exposed
Console.WriteLine(Barcode.Value)
Next Barcode
End UsingImports IronOcr
Private ocr As New IronTesseract()
ocr.Configuration.ReadBarCodes = True
Using input As New OcrInput()
input.LoadImage("img/Barcode.png")
Dim Result As OcrResult = ocr.Read(input)
For Each Barcode In Result.Barcodes
' type and location properties also exposed
Console.WriteLine(Barcode.Value)
Next Barcode
End Using画像の特定領域のOCR
IronOCR のすべてのスキャンおよび読み取り方法では、ページのどの部分からテキストを読み取りたいかを正確に指定できます。 これは、標準化されたフォームを参照する場合に非常に役立ち、多くの時間を節約して効率を向上させることができます。
クロップ領域を使用するには、System.Drawing にシステム参照を追加して、System.Drawing.Rectangle オブジェクトを使用できるようにする必要があります。
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
// Dimensions are in pixel
var contentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
input.LoadImage("document.png", contentArea);
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
// Dimensions are in pixel
var contentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
input.LoadImage("document.png", contentArea);
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
' Dimensions are in pixel
Private contentArea = New System.Drawing.Rectangle() With {
.X = 215,
.Y = 1250,
.Height = 280,
.Width = 1335
}
input.LoadImage("document.png", contentArea)
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
' Dimensions are in pixel
Private contentArea = New System.Drawing.Rectangle() With {
.X = 215,
.Y = 1250,
.Height = 280,
.Width = 1335
}
input.LoadImage("document.png", contentArea)
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)低品質スキャン用のOCR
IronOCR OcrInputクラスは、通常のTesseractが読めないスキャンを修正することができます。
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames(@"img\Potter.tiff", pageindices);
// fixes digital noise and poor scanning
input.DeNoise();
// fixes rotation and perspective
input.Deskew();
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames(@"img\Potter.tiff", pageindices);
// fixes digital noise and poor scanning
input.DeNoise();
// fixes rotation and perspective
input.Deskew();
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
Private pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img\Potter.tiff", pageindices)
' fixes digital noise and poor scanning
input.DeNoise()
' fixes rotation and perspective
input.Deskew()
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
Private pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img\Potter.tiff", pageindices)
' fixes digital noise and poor scanning
input.DeNoise()
' fixes rotation and perspective
input.Deskew()
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)OCR結果を検索可能なPDFとしてエクスポートする
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
input.Title = "Quarterly Report";
input.LoadImage("image1.jpeg");
input.LoadImage("image2.png");
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("image3.gif", pageindices);
OcrResult result = ocr.Read(input);
result.SaveAsSearchablePdf("searchable.pdf");using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
input.Title = "Quarterly Report";
input.LoadImage("image1.jpeg");
input.LoadImage("image2.png");
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("image3.gif", pageindices);
OcrResult result = ocr.Read(input);
result.SaveAsSearchablePdf("searchable.pdf");Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
input.Title = "Quarterly Report"
input.LoadImage("image1.jpeg")
input.LoadImage("image2.png")
Dim pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("image3.gif", pageindices)
Dim result As OcrResult = ocr.Read(input)
result.SaveAsSearchablePdf("searchable.pdf")Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
input.Title = "Quarterly Report"
input.LoadImage("image1.jpeg")
input.LoadImage("image2.png")
Dim pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("image3.gif", pageindices)
Dim result As OcrResult = ocr.Read(input)
result.SaveAsSearchablePdf("searchable.pdf")TIFFから検索可能なPDFへの変換
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("example.tiff", pageindices);
ocr.Read(input).SaveAsSearchablePdf("searchable.pdf");using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("example.tiff", pageindices);
ocr.Read(input).SaveAsSearchablePdf("searchable.pdf");Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
Private pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("example.tiff", pageindices)
ocr.Read(input).SaveAsSearchablePdf("searchable.pdf")Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
Private pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("example.tiff", pageindices)
ocr.Read(input).SaveAsSearchablePdf("searchable.pdf")OCR結果をHTMLとしてエクスポート
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
input.Title = "Html Title";
input.LoadImage("image1.jpeg");
OcrResult Result = ocr.Read(input);
Result.SaveAsHocrFile("results.html");using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
input.Title = "Html Title";
input.LoadImage("image1.jpeg");
OcrResult Result = ocr.Read(input);
Result.SaveAsHocrFile("results.html");Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
input.Title = "Html Title"
input.LoadImage("image1.jpeg")
Dim Result As OcrResult = ocr.Read(input)
Result.SaveAsHocrFile("results.html")Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
input.Title = "Html Title"
input.LoadImage("image1.jpeg")
Dim Result As OcrResult = ocr.Read(input)
Result.SaveAsHocrFile("results.html")OCR画像強化フィルター
IronOCRは、OCRパフォーマンスを向上させるためにOcrInputオブジェクトに対してユニークなフィルタを提供します。
画像強調コード例
using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
input.LoadImage("LowQuality.jpeg");
// fixes digital noise and poor scanning
input.DeNoise();
// fixes rotation and perspective
input.Deskew();
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);using IronOcr;
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
input.LoadImage("LowQuality.jpeg");
// fixes digital noise and poor scanning
input.DeNoise();
// fixes rotation and perspective
input.Deskew();
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
input.LoadImage("LowQuality.jpeg")
' fixes digital noise and poor scanning
input.DeNoise()
' fixes rotation and perspective
input.Deskew()
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)Imports IronOcr
Private ocr As New IronTesseract()
Private OcrInput As using
input.LoadImage("LowQuality.jpeg")
' fixes digital noise and poor scanning
input.DeNoise()
' fixes rotation and perspective
input.Deskew()
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)OCR画像フィルターのリスト
IronOCR に組み込まれている OCR パフォーマンスを向上させる入力フィルターには次のものがあります。
OcrInput.Rotate(double degrees)- 画像を時計回りに指定された角度だけ回転させます。反時計回りに回転させるには負の数字を使用します。OcrInput.Binarize()- このフィルターは、すべてのピクセルを黒または白に変換し、中間色をなくします。非常に低いコントラストの画像でOCR性能を向上させる可能性があります。OcrInput.ToGrayScale()- すべてのピクセルをグレースケールの濃淡に変換します。 精度は向上しないかもしれませんが、速度は向上する可能性があります。OcrInput.Contrast()- コントラストを自動的に増加させ、低コントラストのスキャンで速度と精度を向上させることがよくあります。OcrInput.DeNoise()- デジタルノイズを除去します。ノイズが予想される場合のみ推奨します。OcrInput.Invert()- すべての色を反転させます(白は黒に、逆も同様)。OcrInput.Dilate()- 形態の進展を促進し、オブジェクトの境界にピクセルを追加し、Erodeの逆を行います。OcrInput.Erode()- 形態の進展を促進し、オブジェクトの境界からピクセルを削除し、Dilateの逆を行います。OcrInput.Deskew()- 画像を回転させて正しく向きを整えます。 Tesseract のスキュー許容範囲が限られているため便利です。OcrInput.EnhanceResolution- 低品質の画像の解像度を向上させます。 この設定は通常、低 DPI 入力を自動的に管理するために使用されます。EnhanceResolutionは、低解像度の画像(275 dpi未満)を検出し、アップスケールし、テキストをシャープにしてより良いOCR結果を得られるようにします。 時間はかかりますが、全体的な OCR 操作時間が短縮されることが多いです。Language- 22の国際言語パックからの選択をサポートします。Strategy- 速くて正確さの低い戦略と高度な戦略(精度のためにAIを使用)を単語の統計的関係に基づいて選択することを可能にします。ColorSpace- グレースケールまたはカラーでOCRを選択できます。 グレースケールは一般的に最適ですが、特定のコントラストのシナリオではカラーの方が適している場合があります。DetectWhiteTextOnDarkBackgrounds- ネガティブ画像に対応し、自動的に暗い背景の白いテキストを検出して読みます。InputImageType- OCRライブラリをガイドし、全文書を対象にしているかスニペットを対象にしているかを指定します。RotateAndStraighten- IronOCRが回転された文書や視角の歪みを受けた文書を正しく扱うことを可能にします。ReadBarcodes- テキストスキャンと同時にバーコードおよびQRコードを自動的に読み込み、時間の大幅な追加なしに処理を行います。ColorDepth- OCRプロセスでの色深度のためにピクセルあたりのビット数を決定します。 深度を高くすると品質は向上しますが、処理時間も長くなります。
125 言語パック
IronOCRは125の国際言語を言語パックを通じてサポートしており、これらはDLLとして提供され、このウェブサイトからダウンロードできるほか、NuGetパッケージマネージャーからも利用可能です。
言語には、ドイツ語、フランス語、英語、中国語、日本語などがあります。 専門的な言語パックはMRZ、MICRチェック、財務データ、ナンバープレート等に存在します。加えて、カスタムのTesseract「.traineddata」ファイルを使用できます。
言語の例
using IronOcr;
// PM> Install IronOcr.Languages.Arabic
IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.Arabic;
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("img/arabic.gif", pageindices);
// Add image filters if needed
// In this case, even thought input is very low quality
// IronTesseract can read what conventional Tesseract cannot.
OcrResult result = ocr.Read(input);
// Console can't print Arabic on Windows easily.
// Let's save to disk instead.
result.SaveAsTextFile("arabic.txt");using IronOcr;
// PM> Install IronOcr.Languages.Arabic
IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.Arabic;
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames("img/arabic.gif", pageindices);
// Add image filters if needed
// In this case, even thought input is very low quality
// IronTesseract can read what conventional Tesseract cannot.
OcrResult result = ocr.Read(input);
// Console can't print Arabic on Windows easily.
// Let's save to disk instead.
result.SaveAsTextFile("arabic.txt");Imports IronOcr
' PM> Install IronOcr.Languages.Arabic
Private ocr As New IronTesseract()
ocr.Language = OcrLanguage.Arabic
Using input As New OcrInput()
Dim pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img/arabic.gif", pageindices)
' Add image filters if needed
' In this case, even thought input is very low quality
' IronTesseract can read what conventional Tesseract cannot.
Dim result As OcrResult = ocr.Read(input)
' Console can't print Arabic on Windows easily.
' Let's save to disk instead.
result.SaveAsTextFile("arabic.txt")
End UsingImports IronOcr
' PM> Install IronOcr.Languages.Arabic
Private ocr As New IronTesseract()
ocr.Language = OcrLanguage.Arabic
Using input As New OcrInput()
Dim pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img/arabic.gif", pageindices)
' Add image filters if needed
' In this case, even thought input is very low quality
' IronTesseract can read what conventional Tesseract cannot.
Dim result As OcrResult = ocr.Read(input)
' Console can't print Arabic on Windows easily.
' Let's save to disk instead.
result.SaveAsTextFile("arabic.txt")
End Using複数言語の例
複数の言語を同時にOCR処理することも可能です。これにより、Unicode文書内の英語のメタデータやURLのOCR処理能力が向上します。
using IronOcr;
// PM> Install IronOcr.Languages.ChineseSimplified
IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.ChineseSimplified;
// We can add any number of languages
ocr.AddSecondaryLanguage(OcrLanguage.English);
using OcrInput input = new OcrInput();
input.LoadPdf("multi-language.pdf");
OcrResult result = ocr.Read(input);
result.SaveAsTextFile("results.txt");using IronOcr;
// PM> Install IronOcr.Languages.ChineseSimplified
IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.ChineseSimplified;
// We can add any number of languages
ocr.AddSecondaryLanguage(OcrLanguage.English);
using OcrInput input = new OcrInput();
input.LoadPdf("multi-language.pdf");
OcrResult result = ocr.Read(input);
result.SaveAsTextFile("results.txt");Imports IronOcr
' PM> Install IronOcr.Languages.ChineseSimplified
Private ocr As New IronTesseract()
ocr.Language = OcrLanguage.ChineseSimplified
' We can add any number of languages
ocr.AddSecondaryLanguage(OcrLanguage.English)
Using input As New OcrInput()
input.LoadPdf("multi-language.pdf")
Dim result As OcrResult = ocr.Read(input)
result.SaveAsTextFile("results.txt")
End UsingImports IronOcr
' PM> Install IronOcr.Languages.ChineseSimplified
Private ocr As New IronTesseract()
ocr.Language = OcrLanguage.ChineseSimplified
' We can add any number of languages
ocr.AddSecondaryLanguage(OcrLanguage.English)
Using input As New OcrInput()
input.LoadPdf("multi-language.pdf")
Dim result As OcrResult = ocr.Read(input)
result.SaveAsTextFile("results.txt")
End Using詳細なOCR結果オブジェクト
IronOCR は、各操作に対して OCR 結果オブジェクトを返します。 一般的に、開発者はスキャンされたテキストを取得するためにTextプロパティにアクセスします。 ただし、結果オブジェクトにはさらに詳細な情報が含まれています。
using IronOcr;
IronTesseract ocr = new IronTesseract();
// Must be set to true to read barcode
ocr.Configuration.ReadBarCodes = true;
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames(@"img\sample.tiff", pageindices);
OcrResult result = ocr.Read(input);
var pages = result.Pages;
var words = pages[0].Words;
var barcodes = result.Barcodes;
// Explore here to find a massive, detailed API:
// - Pages, Blocks, Paraphaphs, Lines, Words, Chars
// - Image Export, Fonts Coordinates, Statistical Data, Tablesusing IronOcr;
IronTesseract ocr = new IronTesseract();
// Must be set to true to read barcode
ocr.Configuration.ReadBarCodes = true;
using OcrInput input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames(@"img\sample.tiff", pageindices);
OcrResult result = ocr.Read(input);
var pages = result.Pages;
var words = pages[0].Words;
var barcodes = result.Barcodes;
// Explore here to find a massive, detailed API:
// - Pages, Blocks, Paraphaphs, Lines, Words, Chars
// - Image Export, Fonts Coordinates, Statistical Data, TablesImports IronOcr
Private ocr As New IronTesseract()
' Must be set to true to read barcode
ocr.Configuration.ReadBarCodes = True
Using input As New OcrInput()
Dim pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img\sample.tiff", pageindices)
Dim result As OcrResult = ocr.Read(input)
Dim pages = result.Pages
Dim words = pages(0).Words
Dim barcodes = result.Barcodes
' Explore here to find a massive, detailed API:
' - Pages, Blocks, Paraphaphs, Lines, Words, Chars
' - Image Export, Fonts Coordinates, Statistical Data, Tables
End UsingImports IronOcr
Private ocr As New IronTesseract()
' Must be set to true to read barcode
ocr.Configuration.ReadBarCodes = True
Using input As New OcrInput()
Dim pageindices = New Integer() { 1, 2 }
input.LoadImageFrames("img\sample.tiff", pageindices)
Dim result As OcrResult = ocr.Read(input)
Dim pages = result.Pages
Dim words = pages(0).Words
Dim barcodes = result.Barcodes
' Explore here to find a massive, detailed API:
' - Pages, Blocks, Paraphaphs, Lines, Words, Chars
' - Image Export, Fonts Coordinates, Statistical Data, Tables
End Usingパフォーマンス
IronOCR は、パフォーマンスの調整や画像の変更を必要とせず、すぐに使用できます。
速度は驚異的です:IronOCR.2020+は最大10倍の速さで、以前のビルドよりも250%以上少ないエラーを出します。
もっと詳しく知る
C#、VB、F#、または他の.NET言語でのOCRについてもっと知るには当社のコミュニティチュートリアルをお読みください。これらはIronOCRを使用する実際の例を示し、ライブラリを最適化するためのニュアンスを紹介します。
完全な.NET開発者向けのAPIリファレンスも利用可能です。
Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。