如何獲取讀取信心
OCR 讀取信心 (光學字符識別) 指的是OCR系統對其在圖片或文件中識別的文字準確性的確定性或可靠性等級。這是一個衡量OCR系統對識別文字正確性的信心程度的指標。
高置信度分數表示高度確定識別是準確的,而低置信度分數則表明識別可能不太可靠。
如何獲取讀取信心
立即開始在您的專案中使用IronPDF,並享受免費試用。
查看 IronOCR 上 Nuget 快速安裝和部署。已被下載超過800萬次,它正用C#改變OCR。
Install-Package IronOcr
請考慮安裝 IronOCR DLL 直接下載並手動安裝到您的專案或GAC表單: IronOcr.zip
手動安裝到您的項目中
下載DLL獲取讀取信心範例
在對輸入圖像進行 OCR 後,文本的信心級別儲存在 Confidence 屬性中。使用 using
語句來自動處置物件。分別使用 OcrImageInput
和 OcrPdfInput
類別添加圖像和 PDF 文件。Read
方法將返回一個'OcrResult'物件,允許訪問 Confidence 屬性。
:path=/static-assets/ocr/content-code-examples/how-to/tesseract-result-confidence-get-confidence.cs
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
獲取不同層次的讀取信心度
不僅可以檢索整個文檔的信心度,還可以訪問每個頁面、段落、行、字詞和字元的信心度。此外,您還可以獲取塊的信心度,塊代表位於緊密在一起的一個或多個段落的集合。
:path=/static-assets/ocr/content-code-examples/how-to/tesseract-result-confidence-confidence-level.cs
// 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
獲取字符選項
除了信心水平,還有另一個有趣的屬性叫作選項。選項包含了一個替代單詞選項及其統計相關性的列表。這些信息允許使用者訪問其他可能的字符。
:path=/static-assets/ocr/content-code-examples/how-to/tesseract-result-confidence-get-choices.cs
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