抽出された結果の読み取り方法

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

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

読み取りまたはOCR結果には、検出された段落、行、単語、および個々の文字に関する豊富な情報が含まれています。 これらの各要素に対して、結果は詳細な情報のセットを提供します。

各要素について、テキスト内容、正確なXおよびY座標、寸法を提供します (幅と高さ)テキスト方向 (左から右へ、または上から下へ)、および位置をtokenに トリミング矩形 オブジェクト


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をダウンロード

OcrResult内のデータ

結果の値には抽出されたテキストだけでなく、IronOCRによってPDFおよび画像ドキュメント内で発見されたページ、段落、行、単語、文字、およびバーコードに関する情報も含まれています。 Read メソッドを使用して、返された OcrResult オブジェクトからこの情報にアクセスできます。

:path=/static-assets/ocr/content-code-examples/how-to/read-results-output-information.cs
using IronOcr;
using System;
using static IronOcr.OcrResult;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Add image
using var imageInput = new OcrImageInput("sample.jpg");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);

// Retrieve list of detected paragraphs
Paragraph[] paragraphs = ocrResult.Paragraphs;

// Output information to console
Console.WriteLine($"Text: {paragraphs[0].Text}");
Console.WriteLine($"X: {paragraphs[0].X}");
Console.WriteLine($"Y: {paragraphs[0].Y}");
Console.WriteLine($"Width: {paragraphs[0].Width}");
Console.WriteLine($"Height: {paragraphs[0].Height}");
Console.WriteLine($"Text direction: {paragraphs[0].TextDirection}");
Imports IronOcr
Imports System
Imports IronOcr.OcrResult

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Add image
Private imageInput = New OcrImageInput("sample.jpg")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)

' Retrieve list of detected paragraphs
Private paragraphs() As Paragraph = ocrResult.Paragraphs

' Output information to console
Console.WriteLine($"Text: {paragraphs(0).Text}")
Console.WriteLine($"X: {paragraphs(0).X}")
Console.WriteLine($"Y: {paragraphs(0).Y}")
Console.WriteLine($"Width: {paragraphs(0).Width}")
Console.WriteLine($"Height: {paragraphs(0).Height}")
Console.WriteLine($"Text direction: {paragraphs(0).TextDirection}")
VB   C#
OcrResult内のデータ

各テキスト部分について、例えば段落、行、単語、個々の文字ごとに、次の情報を提供します:

  • テキスト:文字列としての実際のテキスト。
  • X:ページの左端からの位置(ピクセル単位)。
  • Y: ページの上端からピクセル単位の位置。
  • 幅:ピクセル単位の幅。
  • 高さ: ピクセル単位の高さ。
  • テキスト方向: テキストが読まれる方向。例として、「左から右」や「上から下」などがあります。

  • 場所: このテキストがページ上のどこにあるかを示すピクセル単位の矩形。

段落、行、単語、文字の比較

以下は、検出された段落、行、単語、および文字の比較です。

該当の段落を強調表示
行をハイライト
単語を強調
ハイライト文字

バーコードおよびQRコード

その通りです! IronOCRはバーコードとQRコードを読み取ることができます。 機能はIronBarcodeほど強力ではないかもしれませんが、IronOcrも一般的なバーコードタイプのサポートを提供しています。バーコード検出を有効にするには、Configuration.ReadBarCodesプロパティをtrueに設定してください。

加えて、検出されたバーコードからその形式、値、座標を含む貴重な情報を抽出することができます。 (x、y)高さ、幅、位置を IronSoftware.Drawing.Rectangle オブジェクトとして。 このRectangleクラスでは アイアンドローイング (アイアンドローイング (IronDrawing)) 文書上の正確な位置決めを可能にします。

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

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Enable barcodes detection
ocrTesseract.Configuration.ReadBarCodes = true;

// Add image
using OcrInput ocrInput = new OcrInput();
ocrInput.LoadPdf("sample.pdf");

// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(ocrInput);

// Output information to console
foreach(var barcode in ocrResult.Barcodes)
{
    Console.WriteLine("Format = " + barcode.Format);
    Console.WriteLine("Value = " + barcode.Value);
    Console.WriteLine("X = " + barcode.X);
    Console.WriteLine("Y = " + barcode.Y);
}
Console.WriteLine(ocrResult.Text);
Imports IronOcr
Imports System
Imports IronOcr.OcrResult

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Enable barcodes detection
ocrTesseract.Configuration.ReadBarCodes = True

' Add image
Using ocrInput As New OcrInput()
	ocrInput.LoadPdf("sample.pdf")
	
	' Perform OCR
	Dim ocrResult As OcrResult = ocrTesseract.Read(ocrInput)
	
	' Output information to console
	For Each barcode In ocrResult.Barcodes
		Console.WriteLine("Format = " & barcode.Format)
		Console.WriteLine("Value = " & barcode.Value)
		Console.WriteLine("X = " & barcode.X)
		Console.WriteLine("Y = " & barcode.Y)
	Next barcode
	Console.WriteLine(ocrResult.Text)
End Using
VB   C#

出力

バーコードを検出

チャクニット・ビン

ソフトウェアエンジニア

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