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

Chaknith related to 抽出された結果の読み取り方法
チャクニット・ビン
2023年10月31日
更新済み 2024年12月10日
共有:
This article was translated from English: Does it need improvement?
Translated
View the article in English

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

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

IronOCRを始めましょう

今日から無料トライアルでIronOCRをあなたのプロジェクトで使い始めましょう。

最初のステップ:
green arrow pointer



OcrResult内のデータ

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

: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}")
$vbLabelText   $csharpLabel
OcrResultのデータ

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

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

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

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

Highlight paragraph
Highlight line
Highlight word
ハイライト文字

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

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

さらに、有用な情報は、検出されたバーコードから抽出できます。それには、フォーマット、値、座標 (x, y)、高さ、幅、および IronSoftware.Drawing.Rectangle オブジェクトとしての位置が含まれます。 このRectangleクラスは、ドキュメント上での正確な位置決めを可能にします。

: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
$vbLabelText   $csharpLabel

出力

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