How to get Read Confidence

by Chaknith Bin

Read confidence in OCR (Optical Character Recognition) refers to the level of certainty or reliability that the OCR system assigns to the accuracy of the text it has recognized in an image or document. It is a measure of how confident the OCR system is that the recognized text is correct.

A high confidence score indicates a high degree of certainty that the recognition is accurate, while a low confidence score suggests that the recognition may be less reliable.

Get started with IronOCR

Start using IronOCR in your project today with a free trial.

First Step:
green arrow pointer



Get Read Confidence Example

After performing OCR on the input image, the confidence level of the text is stored in the Confidence property. Utilize the 'using' statement to automatically dispose of objects. Add documents such as images and PDFs with the OcrImageInput and OcrPdfInput class, respectively. The Read method will return an 'OcrResult' object that allows access to the Confidence property

: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
VB   C#

Get Read Confidences at Different Levels

Not only can you retrieve the confidence level of the entire document, but you can also access the confidence levels of each page, paragraph, line, word, and character. Furthermore, you can obtain the confidence of a block, which represents a collection of one or more paragraphs located closely together.

: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
VB   C#

Get Character Choices

Apart from the confidence level, there is another interesting property called Choices. Choices contain a list of alternative word choices and their statistical relevance. This information allows the user to access other possible characters.

: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
VB   C#

Retrieved Information

Choices
Chaknith related to Retrieved Information

Chaknith Bin

Software Engineer

Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking.