どのようにIronOCRでC# OCRの読み取りに自信をつけるか
IronOCRの読み取り信頼度は、OCRシステムが認識されたテキストの精度についてどれほど確信を持っているかを示し、0から100までの値を持ちます。高いスコアは大きな信頼性を意味します—すべてのConfidenceプロパティを介してアクセスできます。
OCR (光学式文字認識) における読み取り信頼性とは、OCR システムが画像または文書内で認識したテキストの正確さに割り当てる確実性または信頼性のレベルを指します。 これは、OCR システムが認識したテキストが正しいとどの程度確信しているかを示す指標です。 スキャンされたドキュメント、写真、またはテキストの品質が変化する可能性のある画像を処理する場合、このメトリックは特に重要になります。
信頼スコアが高い場合、認識が正確であることの確実性が高いことを示し、信頼スコアが低い場合、認識の信頼性が低い可能性があることを示します。 これらの信頼レベルを理解することは、開発者がアプリケーションに適切な検証ロジックとエラー処理を実装するのに役立ちます。
クイックスタート: 1行でOCR読み取りの信頼度を取得Confidenceプロパティにアクセスして、そのテキスト認識についてIronOCRがどれだけ確信を持っているかを確認します。 OCR出力の精度を評価し始めるには、シンプルで信頼できる方法です。
-
1Install IronOCR with NuGet Package Manager
-
2このコード スニペットをコピーして実行します。
double confidence = new IronOcr.IronTesseract().Read("input.png").Confidence;C# -
3実際の環境でテストするためにデプロイする
今日プロジェクトで IronOCR を使い始めましょう無料トライアル
最小限のワークフロー(5ステップ)
- 読み取り信頼性にアクセスするための C# ライブラリをダウンロードする
- 対象の画像とPDFドキュメントを準備する
- OCR 結果の
Confidenceプロパティにアクセスします。 - ページ、段落、行、単語、文字の信頼度を取得
選択肢プロパティで別の単語の選択肢を確認してください。
C#に自信を持つにはどうすればよいですか?
入力画像に対してOCRを実行した後、テキストの信頼レベルはConfidenceプロパティに格納されます。 "using"ステートメントを利用して、使用後にオブジェクトを自動的に破棄します。 OcrPdfInputクラスを使用して、画像やPDFなどのドキュメントを追加します。 Confidenceプロパティにアクセスすることを可能にするOcrResultオブジェクトを返します。
using IronOcr;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Add image
using var imageInput = new OcrImageInput("sample.tiff");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Get confidence level
double confidence = ocrResult.Confidence;Imports IronOcr
' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()
' Add image
Private imageInput = New OcrImageInput("sample.tiff")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Get confidence level
Private confidence As Double = ocrResult.Confidence返される信頼度の範囲は0~100です:
- 90-100:優れた信頼性 - テキストの信頼性が高い。
- 80-89:良好な信頼性 - テキストは、わずかな不確実性はあるが、概ね正確である。
- 70-79:信頼度は中程度 - テキストには多少の誤りが含まれる可能性があります。
- 70未満:信頼度が低い - テキストを見直すか、再処理する必要があります。
さまざまなレベルで信頼を得るにはどうすればよいですか?
文書全体の信頼度レベルを取得できるだけでなく、各ページ、段落、行、単語、文字の信頼度レベルにアクセスすることもできます。 さらに、近接して配置された 1 つ以上の段落の集合を表すブロックの信頼度を取得することもできます。
// Get page confidence level
double pageConfidence = ocrResult.Pages[0].Confidence;
// Get paragraph confidence level
double paragraphConfidence = ocrResult.Paragraphs[0].Confidence;
// Get line confidence level
double lineConfidence = ocrResult.Lines[0].Confidence;
// Get word confidence level
double wordConfidence = ocrResult.Words[0].Confidence;
// Get character confidence level
double characterConfidence = ocrResult.Characters[0].Confidence;
// Get block confidence level
double blockConfidence = ocrResult.Blocks[0].Confidence;' Get page confidence level
Dim pageConfidence As Double = ocrResult.Pages(0).Confidence
' Get paragraph confidence level
Dim paragraphConfidence As Double = ocrResult.Paragraphs(0).Confidence
' Get line confidence level
Dim lineConfidence As Double = ocrResult.Lines(0).Confidence
' Get word confidence level
Dim wordConfidence As Double = ocrResult.Words(0).Confidence
' Get character confidence level
Dim characterConfidence As Double = ocrResult.Characters(0).Confidence
' Get block confidence level
Dim blockConfidence As Double = ocrResult.Blocks(0).Confidence実例:信頼度によるフィルタリング
低品質スキャンなど、さまざまな品質のドキュメントを処理する場合、信頼度スコアを使用して結果をフィルタリングできます:
using IronOcr;
using System.Linq;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Configure for better accuracy
ocrTesseract.Configuration.ReadBarCodes = false;
ocrTesseract.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd;
// Add image
using var imageInput = new OcrImageInput("invoice.png");
// Apply filters to improve quality
imageInput.Deskew();
imageInput.DeNoise();
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Filter words with confidence above 85%
var highConfidenceWords = ocrResult.Words
.Where(word => word.Confidence >= 85)
.Select(word => word.Text)
.ToList();
// Process only high-confidence text
string reliableText = string.Join(" ", highConfidenceWords);
Console.WriteLine($"High confidence text: {reliableText}");
// Flag low-confidence words for manual review
var lowConfidenceWords = ocrResult.Words
.Where(word => word.Confidence < 85)
.Select(word => new { word.Text, word.Confidence })
.ToList();
foreach (var word in lowConfidenceWords)
{
Console.WriteLine($"Review needed: '{word.Text}' (Confidence: {word.Confidence:F2}%)");
}Imports IronOcr
Imports System.Linq
' Instantiate IronTesseract
Dim ocrTesseract As New IronTesseract()
' Configure for better accuracy
ocrTesseract.Configuration.ReadBarCodes = False
ocrTesseract.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd
' Add image
Using imageInput As New OcrImageInput("invoice.png")
' Apply filters to improve quality
imageInput.Deskew()
imageInput.DeNoise()
' Perform OCR
Dim ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Filter words with confidence above 85%
Dim highConfidenceWords = ocrResult.Words _
.Where(Function(word) word.Confidence >= 85) _
.Select(Function(word) word.Text) _
.ToList()
' Process only high-confidence text
Dim reliableText As String = String.Join(" ", highConfidenceWords)
Console.WriteLine($"High confidence text: {reliableText}")
' Flag low-confidence words for manual review
Dim lowConfidenceWords = ocrResult.Words _
.Where(Function(word) word.Confidence < 85) _
.Select(Function(word) New With {Key .Text = word.Text, Key .Confidence = word.Confidence}) _
.ToList()
For Each word In lowConfidenceWords
Console.WriteLine($"Review needed: '{word.Text}' (Confidence: {word.Confidence:F2}%)")
Next
End UsingOCRにおける文字の選択とは
信頼レベルとは別に、Choicesという別の興味深いプロパティがあります。 選択肢には、代替単語の選択肢とその統計的関連性のリストが含まれます。 この情報により、ユーザーは他の可能な文字にアクセスできるようになります。 この機能は、複数の言語や特殊なフォントを扱う場合に特に役立ちます。
using IronOcr;
using static IronOcr.OcrResult;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Add image
using var imageInput = new OcrImageInput("Potter.tiff");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Get choices
Choice[] choices = ocrResult.Characters[0].Choices;Imports IronOcr
Imports IronOcr.OcrResult
' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()
' Add image
Private imageInput = New OcrImageInput("Potter.tiff")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Get choices
Private choices() As Choice = ocrResult.Characters(0).Choices代替文字の選択はどのように役立ちますか?
代替文字の選択にはいくつかの利点があります:
- 曖昧解決: 'O'と'0'や'l'と'1'のような文字が混同される場合
- フォントのバリエーション: スタイリッシュまたは装飾的なフォントのさまざまな解釈
- 品質の問題: 劣化したテキストを扱う場合に複数の可能性が発生する 4.言語コンテキスト:言語ルールに基づく代替解釈

文字の選択を扱う
以下は、精度を向上させるための文字選択肢の使用方法を示す包括的な例です:
using IronOcr;
using System;
using System.Linq;
using static IronOcr.OcrResult;
// Configure IronTesseract for detailed results
IronTesseract ocrTesseract = new IronTesseract();
// Process image with potential ambiguities
using var imageInput = new OcrImageInput("ambiguous_text.png");
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Analyze character choices for each word
foreach (var word in ocrResult.Words)
{
Console.WriteLine($"\nWord: '{word.Text}' (Confidence: {word.Confidence:F2}%)");
// Check each character in the word
foreach (var character in word.Characters)
{
if (character.Choices != null && character.Choices.Length > 1)
{
Console.WriteLine($" Character '{character.Text}' has alternatives:");
// Display all choices sorted by confidence
foreach (var choice in character.Choices.OrderByDescending(c => c.Confidence))
{
Console.WriteLine($" - '{choice.Text}': {choice.Confidence:F2}%");
}
}
}
}Imports IronOcr
Imports System
Imports System.Linq
Imports IronOcr.OcrResult
' Configure IronTesseract for detailed results
Dim ocrTesseract As New IronTesseract()
' Process image with potential ambiguities
Using imageInput As New OcrImageInput("ambiguous_text.png")
Dim ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Analyze character choices for each word
For Each word In ocrResult.Words
Console.WriteLine(vbCrLf & $"Word: '{word.Text}' (Confidence: {word.Confidence:F2}%)")
' Check each character in the word
For Each character In word.Characters
If character.Choices IsNot Nothing AndAlso character.Choices.Length > 1 Then
Console.WriteLine($" Character '{character.Text}' has alternatives:")
' Display all choices sorted by confidence
For Each choice In character.Choices.OrderByDescending(Function(c) c.Confidence)
Console.WriteLine($" - '{choice.Text}': {choice.Confidence:F2}%")
Next
End If
Next
Next
End Using高度な自信戦略
パスポート、ナンバープレート、MICR小切手のような専門的な文書を扱う場合、信頼スコアが検証のために重要になります:
using IronOcr;
public class DocumentValidator
{
private readonly IronTesseract ocr = new IronTesseract();
public bool ValidatePassportNumber(string imagePath, double minConfidence = 95.0)
{
using var input = new OcrImageInput(imagePath);
// Configure for passport reading
ocr.Configuration.ReadBarCodes = true;
ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.SingleLine;
// Apply preprocessing
input.Deskew();
input.Scale(200); // Upscale for better accuracy
var result = ocr.Read(input);
// Find passport number pattern
var passportLine = result.Lines
.Where(line => line.Text.Contains("P<") || IsPassportNumberFormat(line.Text))
.FirstOrDefault();
if (passportLine != null)
{
Console.WriteLine($"Passport line found: {passportLine.Text}");
Console.WriteLine($"Confidence: {passportLine.Confidence:F2}%");
// Only accept if confidence meets threshold
return passportLine.Confidence >= minConfidence;
}
return false;
}
private bool IsPassportNumberFormat(string text)
{
// Simple passport number validation
return System.Text.RegularExpressions.Regex.IsMatch(text, @"^[A-Z]\d{7,9}$");
}
}Imports IronOcr
Public Class DocumentValidator
Private ReadOnly ocr As New IronTesseract()
Public Function ValidatePassportNumber(imagePath As String, Optional minConfidence As Double = 95.0) As Boolean
Using input As New OcrImageInput(imagePath)
' Configure for passport reading
ocr.Configuration.ReadBarCodes = True
ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.SingleLine
' Apply preprocessing
input.Deskew()
input.Scale(200) ' Upscale for better accuracy
Dim result = ocr.Read(input)
' Find passport number pattern
Dim passportLine = result.Lines _
.Where(Function(line) line.Text.Contains("P<") OrElse IsPassportNumberFormat(line.Text)) _
.FirstOrDefault()
If passportLine IsNot Nothing Then
Console.WriteLine($"Passport line found: {passportLine.Text}")
Console.WriteLine($"Confidence: {passportLine.Confidence:F2}%")
' Only accept if confidence meets threshold
Return passportLine.Confidence >= minConfidence
End If
Return False
End Using
End Function
Private Function IsPassportNumberFormat(text As String) As Boolean
' Simple passport number validation
Return System.Text.RegularExpressions.Regex.IsMatch(text, "^[A-Z]\d{7,9}$")
End Function
End Class信頼性を高めるために最適化する
より高い信頼性スコアを得るには、画像フィルタと前処理テクニックの使用を検討してください:
using IronOcr;
// Create an optimized OCR workflow
IronTesseract ocr = new IronTesseract();
using var input = new OcrImageInput("low_quality_scan.jpg");
// Apply multiple filters to improve confidence
input.Deskew(); // Correct rotation
input.DeNoise(); // Remove noise
input.Sharpen(); // Enhance edges
input.Dilate(); // Thicken text
input.Scale(150); // Upscale for clarity
// Configure for accuracy over speed
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractOnly;
var result = ocr.Read(input);
Console.WriteLine($"Document confidence: {result.Confidence:F2}%");
// Generate confidence report
var confidenceReport = result.Pages
.Select((page, index) => new
{
PageNumber = index + 1,
Confidence = page.Confidence,
WordCount = page.Words.Length,
LowConfidenceWords = page.Words.Count(w => w.Confidence < 80)
});
foreach (var page in confidenceReport)
{
Console.WriteLine($"Page {page.PageNumber}: {page.Confidence:F2}% confidence");
Console.WriteLine($" Total words: {page.WordCount}");
Console.WriteLine($" Low confidence words: {page.LowConfidenceWords}");
}Imports IronOcr
' Create an optimized OCR workflow
Dim ocr As New IronTesseract()
Using input As New OcrImageInput("low_quality_scan.jpg")
' Apply multiple filters to improve confidence
input.Deskew() ' Correct rotation
input.DeNoise() ' Remove noise
input.Sharpen() ' Enhance edges
input.Dilate() ' Thicken text
input.Scale(150) ' Upscale for clarity
' Configure for accuracy over speed
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractOnly
Dim result = ocr.Read(input)
Console.WriteLine($"Document confidence: {result.Confidence:F2}%")
' Generate confidence report
Dim confidenceReport = result.Pages _
.Select(Function(page, index) New With {
.PageNumber = index + 1,
.Confidence = page.Confidence,
.WordCount = page.Words.Length,
.LowConfidenceWords = page.Words.Count(Function(w) w.Confidence < 80)
})
For Each page In confidenceReport
Console.WriteLine($"Page {page.PageNumber}: {page.Confidence:F2}% confidence")
Console.WriteLine($" Total words: {page.WordCount}")
Console.WriteLine($" Low confidence words: {page.LowConfidenceWords}")
Next
End Usingまとめ
OCR信頼度スコアを理解し活用することは、堅牢な文書処理アプリケーションを構築するために不可欠です。 IronOCRの信頼性プロパティと文字の選択肢を活用することで、開発者はOCRワークフローにインテリジェントな検証、エラー処理、品質保証メカニズムを実装することができます。 スクリーンショット、表、または特殊なドキュメントを処理しているかどうかにかかわらず、信頼度スコアは、正確なテキスト抽出を保証するために必要なメトリックを提供します。
よくある質問
OCRの信頼性とは何ですか?
OCR信頼度とは、OCRシステムがテキスト認識の正確さをどの程度確信しているかを示す0から100までの指標です。IronOCRはOcrResultオブジェクトのConfidenceプロパティを通してこの指標を提供し、開発者が認識したテキストの信頼性を評価するのに役立ちます。
C#でOCRの信頼性をすばやく確認するにはどうすればよいですか?
IronOCRを使えば、たった1行のコードでOCRの信頼度を得ることができます: double confidence = new IronOcr.IronTesseract().Read("input.png").Confidence; これはIronOCRがテキスト認識についてどの程度確信しているかを示す0-100の信頼度スコアを返します。
異なる信頼度スコアの範囲は何を意味しますか?
IronOCRの信頼度スコアは以下の通りです:90-100 (Excellent)は、テキストの信頼性が高いことを意味します。80-89 (Good)は、わずかな不確実性はあるものの、テキストが概ね正確であることを意味します。70-79 (Moderate)は、テキストに若干の誤りが含まれている可能性があることを意味します。
さまざまなテキスト要素の信頼レベルにアクセスするにはどうすればよいですか?
IronOCRは、ページ、段落、行、単語、個々の文字など、複数の粒度で信頼度を取得することができます。OCRを実行した後、OcrResultオブジェクト構造を通して各レベルのConfidenceプロパティにアクセスすることができます。
信頼度スコア付きの代替単語候補を入手できますか?
はい、IronOCRは選択肢を信頼度スコアとともに提供するChoicesプロパティを提供しています。この機能は、OCRエンジンが同じテキストについて複数の解釈の可能性を識別した場合に役立ち、スマートな検証ロジックを実装することができます。
アプリケーションに信頼ベースの検証を実装するにはどうすればよいですか?
IronOCRのReadメソッドを使用した後、OcrResultのConfidenceプロパティをチェックしてください。信頼度のしきい値に基づいた条件ロジックを実装する - 例えば、90以上の結果は自動的に受け入れ、70-90の結果はレビューのためにフラグを立て、70以下の結果は再処理または手動で検証する。
What are character choices in IronOCR?
Character choices in IronOCR refer to alternative word choices and their relevance metrics provided during OCR. This feature is useful for handling ambiguities and understanding potential character variations in the text.
How can character choices aid in text recognition?
Character choices help resolve ambiguities by offering alternative interpretations for similar-looking characters and words. This is particularly beneficial when dealing with font variations, degraded text, and multiple languages.
What preprocessing techniques improve IronOCR text accuracy?
Preprocessing techniques such as deskewing, denoising, sharpening, and scaling can significantly enhance text accuracy by improving image quality before executing OCR processes with IronOCR.
How does IronOCR handle low confidence recognition results?
IronOCR allows you to filter and flag low-confidence recognition results for review. You can identify words with confidence scores below a certain threshold and address uncertainties by using validation or reprocessing strategies.

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