他のコンポーネントと比較

アイロン書類認識(IronOCR)とダイナムソフト書類認識(Dynamsoft OCR)の比較

更新済み 6月 13, 2022
共有:

光学文字認識(OCR)は、手書きおよび印刷されたテキストの認識とデジタル化を伴うデータ入力プロセスです。 それは、印刷されたテキストのデジタル写真を解析し、ワードプロセッサなどの他のプログラムで使用できる文字や数字に変換する画像解析を用いたコンピュータ技術の一種です。 テキストはコンピュータ上で検索および変更が可能なように文字コードに変換されます。

過去にはすべての文書が物理的なものであり、未来にはすべての文書がデジタルな社会になるかもしれませんが、現在はその過渡期にあります。 物理的なドキュメントとデジタルドキュメントはこの移行期に共存しています。そのため、OCRのような技術は、相互変換のために非常に重要です。

ドキュメントの復旧、データ入力、およびアクセシビリティは、OCRの用途の一部に過ぎません。 OCRアプリケーションの大半はスキャンされた書類から来ていますが、写真が使用されることもあります。 OCRは非常に貴重な時間節約手段です。なぜなら、資料を再入力することが通常唯一の他の選択肢だからです。 以下は、OCRの使用例です:

  • スキャンされた文書(ファックスを含む)から編集可能なテキストファイルを復元できます。
  • フォームは、手書きの内容を近似して分類されます。
  • 書籍のスキャンを使用して、検索可能で編集可能な電子書籍を作成する。
  • スクリーンショットの写真を使用してテキストを検索および変更します。

  • テキスト読み上げ技術は、視覚障害者に本を読むために使用されます。

    これらはOCRの用途のほんの一部にすぎませんが、この技術がさまざまな業界での汎用性を示しています。 ほぼ全ての企業の全ての従業員は、日常的に文書に大きく依存しているため、ビジネス利用はOCRシステム開発における重要な考慮事項です。

    この記事では、最も強力な2つのOCRリーダーを比較します。

  • IronOCR (アイアンOCR)
  • ダイナミックソフトOCR

    IronOCRとDynamsoft OCRは、スキャンされた画像の変換およびPDFドキュメントのOCR処理をサポートする2つの.NET OCRライブラリです。 数行のコードで画像を検索可能なテキストに変換できます。 単語、文字、段落を個別に取得することもできます。

IronOCR ー 優れた機能

IronOCR は、スキャンが正確に行われていない画像やPDFドキュメントからテキストを検出、読み取り、解釈するユニークな能力を提供します。 IronOCRは、一番速いとは限りませんが、ドキュメントや写真からテキストを抽出する最も簡単な方法を提供します。これは、低品質のスキャンを自動的に鮮明化し、補正することで、傾き、歪み、背景ノイズ、視点の問題を減らし、解像度とコントラストも向上させるからです。

IronOCRを使用すると、開発者は単一または複数ページのスキャン画像を送信でき、すべてのテキスト、バーコード、およびQR情報を返します。 OCRライブラリのクラスセットは、ウェブベース、デスクトップ、またはコンソールアプリケーションにOCR機能を追加します。 Tesseract OCR C#、およびネットアプリでは、JPG、PNG、TIFF、PDF、GIF、BMPなどの形式を入力として使用できます。

IronOCRの光学文字認識 (OCR (光学式文字認識)) エンジンは、多くの一般的なフォント、イタリック体、太字、および下線を使用して準備されたテキストを読み取ることができます。 クロッピングクラスにより、OCRが迅速かつ正確に機能するようになります。 複数ページにわたるドキュメントを扱う際、IronOCRのマルチスレッドエンジンがOCRを高速化します。

IronOCRの特徴

Tesseractの管理には、次の点でユニークであるIronOCRを利用しています:

  • 純粋な.NETでそのまま動作します
  • あなたのマシンにTesseractをインストールする必要はありません。
  • 最新エンジンを実行:Tesseract 5 ( Tesseract 4および3)
  • 以下のプラットフォームで利用可能: .NET Framework 4.5以上、.NET Standard 2以上、および .NET Core 2、3 & .NET 5
  • 従来のTesseractよりも精度と速度が向上しました
  • Xamarin、Mono、Azure、Dockerに対応
  • NuGetパッケージを使用して、複雑なTesseract辞書システムを管理します。
  • 設定なしでPDF、マルチフレームTIFF、およびすべての主要な画像形式をサポート

  • 低品質で歪んだスキャンを修正し、Tesseractから最良の結果を得ることができます。

Dynamsoft OCR - 機能

Dynamsoft.NET OCRライブラリは、迅速かつ信頼性の高い光学式文字認識を提供する.NETコンポーネントです。 C#またはVB.NETで.NETデスクトップアプリケーションを作成するために使用されます。 基本的なOCR APIを使用して、PDFや写真内の無意味なテキストを編集、検索、アーカイブなどのためにデジタルテキストに変換するコードを簡単に作成できます。

スキャナーやその他のTWAIN対応デバイスからの画像は、次の方法で取得できます:

  • ネイティブ、バッファーメモリおよびディスクファイルの画像転送メカニズムすべてに対応しています。
  • オートドキュメントフィーダーを使用すると、バッチスキャンが可能です。 (ADF).
  • TWAIN属性を使用して、一般的なデバイス機能を変更することができます。
  • IfAutoFeed、IfAutoScan、解像度、ビット深度、明るさ、コントラスト、単位、両面、およびその他の機能はすべて変更可能です。
  • 空白ページの検出をサポートします。
  • スキャナープロファイルの変更と保存が可能です。

    UVCおよびWIAに準拠したWebカメラから画像をキャプチャする:

  • 選択したウェブカメラから写真をキャプチャしながらライブビデオフィードを表示します。
  • カメラの設定をカスタマイズします:明るさ、コントラスト、色相、彩度、シャープネス、ガンマ、ホワイトバランス、逆光補正、ゲイン、カラーイネーブル、ズーム、フォーカス、露出、アイリス、パン、チルト、ロール。

    強力な画像読み込み/表示

  • BMP、JPEG、PNG、TIFF、およびマルチページTIFF形式の画像を読み込むことができます。
  • 写真のズームインおよびズームアウトがサポートされています。
  • 画像は、ローカルドライブ、FTPサーバー、HTTPサーバー、またはデータベースから取得できます。
  • 最も包括的な.NETイメージングコンポーネントセットの一つを使用して、BMP、JPEG、PNG、およびTIFFの画像をデコード。

    保存およびアップロード/ダウンロード

  • ファイルストリームを介して写真の読み書きを可能にします。
  • キャプチャした写真をBMP、JPEG、PNG、TIFF、または複数ページのTIFFとしてローカルドライブ、ウェブサーバー、またはデータベースに保存することをサポートします。
  • RLE、G3/G4、LZW、PackBits、およびTIFF圧縮がすべてサポートされています。
  • HTTPSアップロードおよびダウンロードがサポートされています。
  • 最も広範な.NET画像コンポーネントのセットの一つであり、BMP、JPEG、PNG、およびTIFFの画像エンコードをサポートします。
  • 新しく取得した写真を既存のTIFFファイルに添付することができます。

ASP.NETでスキャンしたPDFやその他の画像からテキストを読み取る(光学文字認識)

今日のスピードの速い世界では、顧客は仕事が迅速に完了することを望んでいます。 緊急のプロジェクトを抱えているお客様は頻繁に私たちに連絡を取ります。 我々の技術は、画像の内容を簡単に認識し、プロジェクトが画像を含む書類のスキャンを必要とする場合、その内容をテキストに変換することができます。 光学文字認識 (OCR) (OCR (光学式文字認識)) 時間とコストを節約し、データ入力エラーを減らします。

IronOCRの使用

IronOCRは、OCR変換を実行するためにIronOcr.IronTesseractクラスを使用します。

この基本的な例では、IronOcr.IronTesseract クラスを使用して画像からテキストを読み取り、その結果を文字列として自動的に返します。

// PM> Install-Package IronOcr
using IronOcr;
var Result = new IronTesseract().Read(@"img\Screenshot.png");
Console.WriteLine(Result.Text);
// PM> Install-Package IronOcr
using IronOcr;
var Result = new IronTesseract().Read(@"img\Screenshot.png");
Console.WriteLine(Result.Text);
' PM> Install-Package IronOcr
Imports IronOcr
Private Result = (New IronTesseract()).Read("img\Screenshot.png")
Console.WriteLine(Result.Text)
VB   C#

その結果、以下の段落は100パーセント正確です: もちろんです!翻訳したいコンテンツを提供してください。それに従って正確な日本語訳を提供いたします。

IronOCR シンプルな例

この簡単な例では、C# OCRライブラリの精度をテストし、PNGからテキストを読み取ります。

画像。 これは非常に基本的なテストですが、チュートリアルを続けていくうちにより複雑になっていきます。

迅速な茶色のキツネが怠惰な犬を飛び越える もちろんです!翻訳したいコンテンツを提供してください。それに従って正確な日本語訳を提供いたします。

表面上は簡単に見えるかもしれませんが、表面の裏側では高度な動作が行われています。画像の整列、品質、解像度をスキャンし、その属性を確認し、OCRエンジンを最適化し、最終的に人間のようにテキストを読み取ります。

OCRは機械にとって難しいタスクであり、読み取り速度は人間と同程度である場合があります。 言い換えると、OCRは迅速な手続きではありません。 この場合、全く正しいです。

C# OCRアプリケーションの結果の精度

ほとんどの実際のシナリオでは、開発者はプロジェクトができるだけ早く実行されることを望みます。 このシナリオでは、IronOCRアドオンの名前空間のOcrInputクラスとIronTesseractクラスを代わりに利用することを提案します。

以下のように、OcrInputを使ってOCRジョブの具体的な機能を設定できます。

  • JPEG、TIFF、GIF、BMP、PNGは使用可能な画像形式の一部に過ぎません
  • PDF文書を全体または部分的にインポートすること
  • 画像のコントラスト、解像度、サイズの向上
  • 回転、スキャンノイズ、デジタルノイズ、歪み、ネガティブ画像の修正

    アイアンテッセラクト

    何百もの事前パッケージ化された言語と方言から選択してください

  • すぐにTesseract 5、4、または3のOCRエンジンを使用
  • スクリーンショット、スニペット、またはドキュメント全体を確認する場合は、ドキュメントの種類を指定します。
  • バーコードを認識
  • 検索可能なPDF、Hocr HTML、DOM、文字列はすべてOCR結果のオプションです。
using IronOcr;
var Ocr = new IronTesseract();
using (var Input = new OcrInput(@"img\Potter.tiff")) {
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
using IronOcr;
var Ocr = new IronTesseract();
using (var Input = new OcrInput(@"img\Potter.tiff")) {
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
Imports IronOcr
Private Ocr = New IronTesseract()
Using Input = New OcrInput("img\Potter.tiff")
Dim Result = Ocr.Read(Input)
Console.WriteLine(Result.Text)
End Using
VB   C#

これは中程度の品質のスキャンでも100%の精度で使用できます。

TIFFからC# OCRスキャンの例

ご覧の通り、テキストの読取り (および、必要に応じて、バーコード) TIFFのようなスキャンされた画像からの変換は比較的簡単でした。 このOCRジョブの精度は100パーセントです。

次に、同じページを非常に低品質でスキャンしたものを試してみます。これは、低いDPI、たくさんの歪みやデジタルノイズ、そして元の紙の損傷も含んでいます。

デジタルノイズを含む低解像度スキャンにおけるC# OCR

ここでIronOCRは他のOCRライブラリ、例えばTesseractと比較して、真に優れている点が明らかになります。他のOCRプロジェクトでは、より現実的なスキャン画像ではなく、デジタルで作成された非現実的な「完璧な」テストケースを使用して100%のOCR精度を達成することに焦点を当てており、現実のスキャン画像でのOCR使用についての言及を避けています。

using IronOcr;
var Ocr = new IronTesseract();
using (var Input = new OcrInput(@"img\Potter.LowQuality.tiff"))
{
Input.Deskew(); // removes rotation and perspective
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
using IronOcr;
var Ocr = new IronTesseract();
using (var Input = new OcrInput(@"img\Potter.LowQuality.tiff"))
{
Input.Deskew(); // removes rotation and perspective
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
Imports IronOcr
Private Ocr = New IronTesseract()
Using Input = New OcrInput("img\Potter.LowQuality.tiff")
Input.Deskew() ' removes rotation and perspective
Dim Result = Ocr.Read(Input)
Console.WriteLine(Result.Text)
End Using
VB   C#

Input.Deskew を追加せずに() 画像をまっすぐにするには、52.5%の精度が得られます。 これは不十分です。

Input.Deskewの追加() 99.8% の精度を提供しており、高品質なスキャンのOCRとほぼ同等の正確さです。

Dynamsoft OCRの使用

以下に、Dynamic Web TWAINを使用してJavaScriptでTWAINスキャンおよびクライアントサイドのOCRを行うためのコードスニペットをいくつか紹介します。

画像をスキャン

Dynamic Web TWAINのシンプルなAPIを使用して、スキャン設定を変更し、TWAINスキャナーから写真を取得できます。

function acquireImage()
{
DWObject.SelectSourceByIndex(document.getElementById("source").selectedIndex); //select an available TWAIN scanners

    //set scanning settings like pixel type, resolution, ADF etc.
    DWObject.IfShowUI = false; //don't show the user interface of the scanner
    DWObject.PixelType = 1; //scan in gray
    DWObject.Resolution = 300;
    DWObject.IfFeederEnabled = true; //scan from auto feeder
    DWObject.IfDuplexEnabled = false;
    DWObject.IfDisableSourceAfterAcquire = true;

    //acquire images from scanners
    DWObject.AcquireImage();
}
function acquireImage()
{
DWObject.SelectSourceByIndex(document.getElementById("source").selectedIndex); //select an available TWAIN scanners

    //set scanning settings like pixel type, resolution, ADF etc.
    DWObject.IfShowUI = false; //don't show the user interface of the scanner
    DWObject.PixelType = 1; //scan in gray
    DWObject.Resolution = 300;
    DWObject.IfFeederEnabled = true; //scan from auto feeder
    DWObject.IfDuplexEnabled = false;
    DWObject.IfDisableSourceAfterAcquire = true;

    //acquire images from scanners
    DWObject.AcquireImage();
}
Private Function acquireImage() As [function]
DWObject.SelectSourceByIndex(document.getElementById("source").selectedIndex) 'select an available TWAIN scanners

	'set scanning settings like pixel type, resolution, ADF etc.
	DWObject.IfShowUI = False 'don't show the user interface of the scanner
	DWObject.PixelType = 1 'scan in gray
	DWObject.Resolution = 300
	DWObject.IfFeederEnabled = True 'scan from auto feeder
	DWObject.IfDuplexEnabled = False
	DWObject.IfDisableSourceAfterAcquire = True

	'acquire images from scanners
	DWObject.AcquireImage()
End Function
VB   C#

OCRプロフェッショナルモジュールをダウンロード

クライアントサイドでOCRを使用するためにOCR Professionalモジュールを使用するには、ヘッド内にocrpro.jsを含め、OCR Pro DLLもダウンロードする必要があります。 もちろんです!翻訳したいコンテンツを提供してください。それに従って正確な日本語訳を提供いたします。


Make edits to the .js file:

```js
var CurrentPathName = unescape(location.pathname);
CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf("/") + 1);
DWObject.Addon.OCRPro.Download(CurrentPath + "Resources/addon/OCRPro.zip", OnSuccess, OnFailure);

Recognize text using OCR

Using the JS OCR recognition API to extract text from scanned images is as simple as inserting the code below.

DWObject.Addon.OCRPro.Recognize(0, GetOCRProInfo, GetErrorInfo); // 0 is the index of the image
DWObject.Addon.OCRPro.Recognize(0, GetOCRProInfo, GetErrorInfo); // 0 is the index of the image
DWObject.Addon.OCRPro.Recognize(0, GetOCRProInfo, GetErrorInfo) ' 0 is the index of the image
VB   C#

Reading Cropped Regions of Images

Both sets of software offer solutions for cropping images for OCR.

Reading cropped regions with IronOCR

Iron's branch of Tesseract OCR is adept at reading specific regions of images, as shown in the following code sample.

We can make use of System.Drawing.Rectangle that is used to describe the exact region of an image to be read in pixels.

When dealing with a standardized form that is filled out, and only a portion of the content changes from case to case, this can be really handy.

Scanning a Section of a Page: We can make use of System.Drawing.Rectangle to designate a region in which we shall read a document. Pixels are always the unit of measurement.

We shall find that this improves speed while also avoiding reading needless text. In this example, we will read a student's name from a central region of a standardized paper.

C# OCR Scan From Tiff Example
C# OCR Scan From Tiff Example
using IronOcr;
var Ocr = new IronTesseract();
using (var Input = new OcrInput())
{
// a 41% improvement on speed
var ContentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
Input.AddImage("img/ComSci.png", ContentArea);
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
using IronOcr;
var Ocr = new IronTesseract();
using (var Input = new OcrInput())
{
// a 41% improvement on speed
var ContentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
Input.AddImage("img/ComSci.png", ContentArea);
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
Imports IronOcr
Private Ocr = New IronTesseract()
Using Input = New OcrInput()
' a 41% improvement on speed
Dim ContentArea = New System.Drawing.Rectangle() With {
	.X = 215,
	.Y = 1250,
	.Height = 280,
	.Width = 1335
}
Input.AddImage("img/ComSci.png", ContentArea)
Dim Result = Ocr.Read(Input)
Console.WriteLine(Result.Text)
End Using
VB   C#

This results in a 41 percent boost in speed, while also allowing us to be more specific. This is extremely valuable for .NET OCR applications involving documents that are comparable and consistent, including invoices, receipts, checks, forms, expense claims, and so on.

When reading PDFs, ContentAreas (OCR cropping) is also supported.

Reading cropped regions with Dynamsoft OCR

To begin, launch Visual Studio and build a new C# Windows Forms Application, or open an existing one.

We will need to include DynamicDotNetTWAIN.dll, DynamicOCR.dll, and the appropriate language package. To do so, navigate to Tools -> Choose Toolbox Items, then to the.NET Framework Components tab, click the Browse... button, and locate DynamicDotNetTWAIN.dll in "..Program Files (x86)DynamsoftDynamic.NET TWAIN 4.3 TrialBinv4.0" or v2.0 (depends on the .NET Framework version you are using). Click the OK button. The DynamicDotNetTwain component will then appear in the Toolbox dialog (under the View menu), as illustrated in the accompanying image.

Add Dynamic .NET TWAIN .NET Component

Right-click the project file in Solution Explorer and select Add-> Existing Item... Then, in the file type filter's drop-down list, select All Files. Navigate to  “..\Program Files (x86)\Dynamsoft\Dynamic .NET TWAIN 4.3 Trial\Bin\OCRResources” to add items to the project folder. The .NET TWAIN component can then be dragged and dropped onto the form.

This is the code for clicking the LoadImage button:

private void button1_Click(object sender, EventArgs e) { OpenFileDialog filedlg = new OpenFileDialog(); if (filedlg.ShowDialog() == DialogResult.OK) { dynamicDotNetTwain1.LoadImage(filedlg.FileName);
// choose an image from your local disk and load it into Dynamic .NET TWAIN
} }

We can now attempt to OCR the loaded image and turn it into a searchable text file.

private void dynamicDotNetTwain1_OnImageAreaSelected(short sImageIndex, int left, int top, int right, int bottom) { dynamicDotNetTwain1.OCRTessDataPath = "../../"; // the path of the language package (tessdata)
dynamicDotNetTwain1.OCRLanguage = "eng";
// the language type
dynamicDotNetTwain1.OCRDllPath = "../../";
//the relative path of the OCR DLL file
dynamicDotNetTwain1.OCRResultFormat = Dynamsoft.DotNet.TWAIN.OCR.ResultFormat.Text; byte [] sbytes = dynamicDotNetTwain1.OCR(dynamicDotNetTwain1.CurrentImageIndexInBuffer, left, top, right, bottom);
// OCR the selected area of the image
if (sbytes != null) { SaveFileDialog filedlg = new SaveFileDialog(); filedlg.Filter = "Text File(*.txt) *.txt"; if (filedlg.ShowDialog() == DialogResult.OK) { FileStream fs = File.OpenWrite(filedlg.FileName); fs.Write(sbytes, 0, sbytes.Length);
//save the OCR result as a text file
fs.Close(); } MessageBox.Show("OCR successful"); } else { MessageBox.Show(dynamicDotNetTwain1.ErrorString); } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog filedlg = new OpenFileDialog(); if (filedlg.ShowDialog() == DialogResult.OK) { dynamicDotNetTwain1.LoadImage(filedlg.FileName);
// choose an image from your local disk and load it into Dynamic .NET TWAIN
} }

We can now attempt to OCR the loaded image and turn it into a searchable text file.

private void dynamicDotNetTwain1_OnImageAreaSelected(short sImageIndex, int left, int top, int right, int bottom) { dynamicDotNetTwain1.OCRTessDataPath = "../../"; // the path of the language package (tessdata)
dynamicDotNetTwain1.OCRLanguage = "eng";
// the language type
dynamicDotNetTwain1.OCRDllPath = "../../";
//the relative path of the OCR DLL file
dynamicDotNetTwain1.OCRResultFormat = Dynamsoft.DotNet.TWAIN.OCR.ResultFormat.Text; byte [] sbytes = dynamicDotNetTwain1.OCR(dynamicDotNetTwain1.CurrentImageIndexInBuffer, left, top, right, bottom);
// OCR the selected area of the image
if (sbytes != null) { SaveFileDialog filedlg = new SaveFileDialog(); filedlg.Filter = "Text File(*.txt) *.txt"; if (filedlg.ShowDialog() == DialogResult.OK) { FileStream fs = File.OpenWrite(filedlg.FileName); fs.Write(sbytes, 0, sbytes.Length);
//save the OCR result as a text file
fs.Close(); } MessageBox.Show("OCR successful"); } else { MessageBox.Show(dynamicDotNetTwain1.ErrorString); } }
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
	Dim filedlg As New OpenFileDialog()
	If filedlg.ShowDialog() = DialogResult.OK Then
		dynamicDotNetTwain1.LoadImage(filedlg.FileName)
' choose an image from your local disk and load it into Dynamic .NET TWAIN
	End If
End Sub

We can now attempt [to] OCR the loaded image [and] turn it into a searchable text file.private Sub dynamicDotNetTwain1_OnImageAreaSelected(ByVal sImageIndex As Short, ByVal left As Integer, ByVal top As Integer, ByVal right As Integer, ByVal bottom As Integer)
	dynamicDotNetTwain1.OCRTessDataPath = "../../" ' the path of the language package (tessdata)
dynamicDotNetTwain1.OCRLanguage = "eng"
' the language type
dynamicDotNetTwain1.OCRDllPath = "../../"
'the relative path of the OCR DLL file
dynamicDotNetTwain1.OCRResultFormat = Dynamsoft.DotNet.TWAIN.OCR.ResultFormat.Text
Dim sbytes() As Byte = dynamicDotNetTwain1.OCR(dynamicDotNetTwain1.CurrentImageIndexInBuffer, left, top, right, bottom)
' OCR the selected area of the image
If sbytes IsNot Nothing Then
	Dim filedlg As New SaveFileDialog()
	filedlg.Filter = "Text File(*.txt) *.txt"
	If filedlg.ShowDialog() = DialogResult.OK Then
		Dim fs As FileStream = File.OpenWrite(filedlg.FileName)
		fs.Write(sbytes, 0, sbytes.Length)
'save the OCR result as a text file
fs.Close()
	End If
	MessageBox.Show("OCR successful")
Else
	MessageBox.Show(dynamicDotNetTwain1.ErrorString)
End If
End Sub
VB   C#

This is how the application looks.

Demo App of Zone OCR using Dynamic .NET TWAIN OCR SDK

Image Performance Tuning

The quality of the input image is the most crucial determinant in the speed of an OCR task. The lower the background noise and the higher the dpi, with a great goal value of around 200 dpi, the faster and more accurate the OCR output.

Image Processing Techniques for Dynamsoft OCR

We need to use OCR in a variety of situations, such as scanning a credit card number with our phone or extracting text from paper documents. OCR capabilities are included in Dynamsoft Label Recognition (DLR) and Dynamic Web TWAIN (DWT).

Although they can do an excellent job in general, we can improve the results by using various image processing techniques.

Lighten/remove shadows

Poor illumination may have an impact on the OCR result. To improve the outcome, we can whiten photos or eliminate shadows from images.

Invert

Because the OCR engine is often trained on text in dark colors, text in light colors can be harder to discover and recognize.

Light text

It will be easier to recognize if we invert its color

Light text inverted

To perform the inversion, we can use the GrayscaleTransformationModes parameter in DLR.

Here are the JSON settings:

"GrayscaleTransformationModes": [
    {
        "Mode": "DLR_GTM_INVERTED"
    }
]
"GrayscaleTransformationModes": [
    {
        "Mode": "DLR_GTM_INVERTED"
    }
]
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'"GrayscaleTransformationModes": [{ "Mode": "DLR_GTM_INVERTED" }]
VB   C#

DLR .net’s reading result:

Light text result

Rescale

If the letter height is too low, the OCR engine may not produce a good result. In general, the image should have a DPI of at least 300.

There is a ScaleUpModes parameter in DLR 1.1 that allows you to scale up letters. We may, of course, scale the image ourselves.

Reading the image directly yields the incorrect result:

1x image

After scaling up the image x2, the result is correct:

2x image

Deskew

It is fine if the text is a little distorted. However, if it is overly skewed, the outcome will be adversely altered. To improve the outcome, we need to crop the image.

To accomplish this, we can use the Hough Line Transform in OpenCV.

Skewed image

Here is the code to deskew the image above.

#coding=utf-8
import numpy as np
import cv2
import math
from PIL import Image

def deskew():
src = cv2.imread("neg.jpg",cv2.IMREAD_COLOR)
gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
kernel = np.ones((5,5),np.uint8)
erode_Img = cv2.erode(gray,kernel)
eroDil = cv2.dilate(erode_Img,kernel) # erode and dilate
showAndWaitKey("eroDil",eroDil)

    canny = cv2.Canny(eroDil,50,150) # edge detection
    showAndWaitKey("canny",canny)

    lines = cv2.HoughLinesP(canny, 0.8, np.pi / 180, 90,minLineLength=100,maxLineGap=10) # Hough Lines Transform
    drawing = np.zeros(src.shape [:], dtype=np.uint8)

    maxY=0
    degree_of_bottomline=0
    index=0
    for line in lines:        
        x1, y1, x2, y2 = line [0]            
        cv2.line(drawing, (x1, y1), (x2, y2), (0, 255, 0), 1, lineType=cv2.LINE_AA)
        k = float(y1-y2)/(x1-x2)
        degree = np.degrees(math.atan(k))
        if index==0:
            maxY=y1
            degree_of_bottomline=degree # take the degree of the line at the bottom
        else:        
            if y1>maxY:
                maxY=y1
                degree_of_bottomline=degree
        index=index+1
    showAndWaitKey("houghP",drawing)

    img=Image.fromarray(src)
    rotateImg = img.rotate(degree_of_bottomline)
    rotateImg_cv = np.array(rotateImg) 
    cv2.imshow("rotateImg",rotateImg_cv)
    cv2.imwrite("deskewed.jpg",rotateImg_cv)
    cv2.waitKey()

def showAndWaitKey(winName,img):
cv2.imshow(winName,img)
cv2.waitKey()

if __name__ == "__main__":              
deskew()
#coding=utf-8
import numpy as np
import cv2
import math
from PIL import Image

def deskew():
src = cv2.imread("neg.jpg",cv2.IMREAD_COLOR)
gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
kernel = np.ones((5,5),np.uint8)
erode_Img = cv2.erode(gray,kernel)
eroDil = cv2.dilate(erode_Img,kernel) # erode and dilate
showAndWaitKey("eroDil",eroDil)

    canny = cv2.Canny(eroDil,50,150) # edge detection
    showAndWaitKey("canny",canny)

    lines = cv2.HoughLinesP(canny, 0.8, np.pi / 180, 90,minLineLength=100,maxLineGap=10) # Hough Lines Transform
    drawing = np.zeros(src.shape [:], dtype=np.uint8)

    maxY=0
    degree_of_bottomline=0
    index=0
    for line in lines:        
        x1, y1, x2, y2 = line [0]            
        cv2.line(drawing, (x1, y1), (x2, y2), (0, 255, 0), 1, lineType=cv2.LINE_AA)
        k = float(y1-y2)/(x1-x2)
        degree = np.degrees(math.atan(k))
        if index==0:
            maxY=y1
            degree_of_bottomline=degree # take the degree of the line at the bottom
        else:        
            if y1>maxY:
                maxY=y1
                degree_of_bottomline=degree
        index=index+1
    showAndWaitKey("houghP",drawing)

    img=Image.fromarray(src)
    rotateImg = img.rotate(degree_of_bottomline)
    rotateImg_cv = np.array(rotateImg) 
    cv2.imshow("rotateImg",rotateImg_cv)
    cv2.imwrite("deskewed.jpg",rotateImg_cv)
    cv2.waitKey()

def showAndWaitKey(winName,img):
cv2.imshow(winName,img)
cv2.waitKey()

if __name__ == "__main__":              
deskew()
#coding=utf-8
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'import TryCast(numpy, np) import cv2 import math from PIL import Image def deskew(): src = cv2.imread("neg.jpg",cv2.IMREAD_COLOR) gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY) kernel = np.ones((5,5),np.uint8) erode_Img = cv2.erode(gray,kernel) eroDil = cv2.dilate(erode_Img,kernel) # erode @and dilate showAndWaitKey("eroDil",eroDil) canny = cv2.Canny(eroDil,50,150) # edge detection showAndWaitKey("canny",canny) lines = cv2.HoughLinesP(canny, 0.8, np.pi / 180, 90,minLineLength=100,maxLineGap=10) # Hough Lines Transform drawing = np.zeros(src.shape [:], dtype=np.uint8) maxY=0 degree_of_bottomline=0 index=0 for line in lines: x1, y1, x2, y2 = line [0] cv2.line(drawing, (x1, y1), (x2, y2), (0, 255, 0), 1, lineType=cv2.LINE_AA) k = float(y1-y2)/(x1-x2) degree = np.degrees(math.atan(k)) if index==0: maxY=y1 degree_of_bottomline=degree # take the degree @of the line at the bottom else: if y1> maxY: maxY=y1 degree_of_bottomline=degree index=index+1 showAndWaitKey("houghP",drawing) img=Image.fromarray(src) rotateImg = img.rotate(degree_of_bottomline) rotateImg_cv = np.array(rotateImg) cv2.imshow("rotateImg",rotateImg_cv) cv2.imwrite("deskewed.jpg",rotateImg_cv) cv2.waitKey() def showAndWaitKey(winName,img): cv2.imshow(winName,img) cv2.waitKey() if __name__ == "__main__": deskew()
VB   C#

Lines detected:

Lines detected

Deskewed:

Deskewed image

Image Processing Techniques for IronOCR

The quality of the input image is not important here because IronOCR excels at repairing defective documents (though this is time-consuming and will cause your OCR jobs to use more CPU cycles).

Choosing input image formats with less digital noise, such as TIFF or PNG, can also result in speedier outcomes than lossy image formats, such as JPEG.

The image filters listed below can significantly enhance performance:

OcrInput.Rotate (double degrees) — Rotates images clockwise by a specified number of degrees. Negative integers are used for anti-clockwise rotation.

OcrInput.Binarize() — This image filter makes every pixel either black or white, with no in-between. It may improve OCR performance in circumstances where the text-to-background contrast is very low.

OcrInput.ToGrayScale() — This image filter converts every pixel to a grayscale shade. It is unlikely to improve OCR accuracy, but it may increase speed.

OcrInput.Contrast() — Automatically increases contrast. In low-contrast scans, this filter frequently improves OCR speed and accuracy.

OcrInput.DeNoise() — This filter should be used only when noise is expected.

OcrInput.Invert() — Reverses all colors. For example, white becomes black: black becomes white.

OcrInput.Dilate() — Advanced morphology. Dilation is the process of adding pixels to the edges of objects in an image. (Erode's inverse)

OcrInput. Erode() — an advanced morphology function. Erosion is the process of removing pixels from the edges of objects. (Dilate's inverse)

OcrInput. Deskew() — Rotates an image so that it is orthogonal and the right way up. Because Tesseract tolerance for skewed scans can be as low as 5 degrees, this is quite useful for OCR.

DeepCleanBackgroundNoise() — Removes a lot of background noise. Only use this filter if you know there is a lot of background noise in the document because it can reduce OCR accuracy on clear documents and is quite CPU intensive.

OcrInput.EnhanceResolution — Improves the resolution of low-resolution photos. Because of OcrInput, this filter is rarely used. OcrInput and will detect and resolve low resolution automatically.

We may want to use Iron Tesseract to speed up OCR on higher-quality scans.

If we're looking for speed, we might start here and subsequently turn features back on until the proper balance is struck.

using IronOcr;
var Ocr = new IronTesseract();
// Configure for speed
Ocr.Configuration.BlackListCharacters = "~`$#^*_}{][\\";
Ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto;
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
Ocr.Configuration.EngineMode = TesseractEngineMode.LstmOnly;
Ocr.Language = OcrLanguage.EnglishFast;
using (var Input = new OcrInput(@"img\Potter.tiff"))
{
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
using IronOcr;
var Ocr = new IronTesseract();
// Configure for speed
Ocr.Configuration.BlackListCharacters = "~`$#^*_}{][\\";
Ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto;
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
Ocr.Configuration.EngineMode = TesseractEngineMode.LstmOnly;
Ocr.Language = OcrLanguage.EnglishFast;
using (var Input = new OcrInput(@"img\Potter.tiff"))
{
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Imports IronOcr
Private Ocr = New IronTesseract()
' Configure for speed
Ocr.Configuration.BlackListCharacters = "~`$#^*_}{][\"
Ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5
Ocr.Configuration.EngineMode = TesseractEngineMode.LstmOnly
Ocr.Language = OcrLanguage.EnglishFast
Using Input = New OcrInput("img\Potter.tiff")
	Dim Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
VB   C#

This result is 99.8% accurate compared to the baseline of 100% — but 35% faster.

Licensing and Pricing

Dynamsoft Licensing and Pricing

Per year license. All rates include one year of maintenance, which includes free software upgrades and premium support.

Dynamsoft offers two types of licenses:

Per client device license

The "One Client Device License" provides access to a same-origin Application (same protocol, same host, and same port) to use the software's features from a single client device. An inactive client device is one that has not accessed any software capability for 90 days in a row. An inactive client device's license seat will be instantly freed and made available for usage by any other active client device. When you reach the maximum number of license seats allowed, Dynamsoft will give you an extra 10% of your client device allowance for emergency use. Once the additional client device allowance has been depleted, no new client devices can access and use the software until there are available license seats again. Please keep in mind that exceeding your client device allowance has no effect on any client devices that have already been licensed.

Per-server license

To deploy the application to a single server, a "One Server License" is required. Servers refer to both physical and virtual servers and include, but are not limited to, production servers, failover servers, development servers that are also used for testing, quality assurance servers, testing servers, and staging servers, all of which require a license. Additional licenses are not required for continuous integration servers (build servers) or localhost development servers. The per-server license is only valid for on-premises server installations, and not for cloud deployments.

Pricing for Dynamsoft OCR starts at USD 1,249/year.

IronOCR Licensing and Pricing

As developers, we all want to accomplish our projects with the least amount of money and resources possible — budgeting is critical. Examine the chart to determine which license is best suited to your requirements and budget.

IronOCR provides licenses with a customizable number of developers, projects, and locations, allowing you to fulfill the needs of your project while only paying for the coverage you require.

IronOCR licensing keys enable you to publish your product without a watermark.

Licenses start from $599 and include one year of support and upgrades.

You can also use a trial license key to try IronOCR for free.

Conclusion

Tesseract OCR on Mac, Windows, Linux, Azure OCR, and Docker are all available with IronOCR for C#. .NET Framework 4.0 or above is required,  .NET Standard 2.0+, .NET Core 2.0+, .NET 5, Mono for macOS and Linux, and Xamarin for macOS are all examples of cross-platform development. IronOCR also uses the latest Tesseract 5 engine to read text, barcodes, and QR codes from all major image and PDF formats. In minutes, this library adds OCR functionality to your desktop, console, or web apps! The OCR can also read PDFs and multi-page TIFFs, and it can be saved as a searchable PDF document or XHTML in any OCR Scan. Plain text, barcode data, and an OCR result class encompassing paragraphs, lines, words, and characters are among its data output choices. It is available in 125 languages, including Arabic, Chinese, English, Finnish, French, German, Hebrew, Italian, Japanese, Korean, Portuguese, Russian, and Spanish, but keep in mind that bespoke language packs can also be generated.

The Dynamic .NET TWAIN OCR add-on is a quick and reliable .NET component for Optical Character Recognition that you can use in WinForms and WPF applications written in C# or VB .NET. You can scan documents or capture photos from webcams using Dynamic .NET TWAIN's image capture module, and then conduct OCR on the images to convert the text in the images to text, searchable PDF files, or strings. Multiple Asian languages, as well as Arabic, are offered in addition to English.

IronOCR offers better licensing than Dynamsoft OCR; IronOcr starts at $599 with one year free, while Dynamsoft starts at $1249 with a free trial. IronOCR also offers licenses for multiple users, while with Dynamsoft, you only get one license per user.

While both sets of software aim at offering the best performance in terms of OCR readings of barcodes, image to text, and image to text, IronOCR stands out in that it shines its light even on images that are in pretty bad shape. It automatically puts in place its sophisticated tuning methods to give you the best OCR results. IronOCR also makes use of Tesseract to give you optimal results with little or no errors.

Iron Software is also offering its customers and users the option to grab its entire suite of software in just two clicks. This means that for the price of two of the components in the Iron Software suite, you can currently get all five components and uninterrupted support.

< 以前
IronOCRとTesseract.NETの比較
次へ >
IronOCRとAbbyy Finereaderの比較

準備はできましたか? バージョン: 2024.9 新発売

無料のNuGetダウンロード 総ダウンロード数: 2,290,361 View Licenses >