Send only uncertain words to manual review. The example reads stock.png, a stock label with a blurred bin code.
dotnet add package RecursiveAI.OneOcr dotnet add package RecursiveAI.OneOcr.Models
Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported. OneOcr installs OneImage as a dependency.
using OneImage; using OneOcr; var engine = OcrEngine.LoadBundled(); var page = Image.Load("stock.png") .Ocr(engine); foreach (var word in page.Words) if (word.Confidence < 0.90f) Console.WriteLine(word.Text);
Unzip the example, then dotnet run.
Prints only the words below 90% confidence:
0 1 17
These are OCR’s readings of fragments of the blurred bin code B8Q-172.
The full program
stock.png is in the download. It says “Stock check” on the first line and “Bin code: B8Q-172” on the second. The text printed by OCR is what the recognizer read, not what the image actually says. The program also prints the score and the corners of each word’s box in pixels.
using OneImage; using OneOcr; var engine = OcrEngine.LoadBundled(); var page = Image.Load("stock.png").Ocr(engine); const float threshold = 0.90f; foreach (var word in page.Words.Where(word => word.Confidence < threshold)) { var box = word.Box; Console.WriteLine(FormattableString.Invariant( $"{word.Text}: {word.Confidence:P1} at ({box.Left:0}, {box.Top:0})–({box.Right:0}, {box.Bottom:0})")); }
0: 36.1 % at (305, 102)–(308, 118) 1: 11.4 % at (357, 103)–(360, 117) 17: 52.4 % at (360, 99)–(391, 129)
No flagged words means no recognized word fell below the threshold; missing words don’t get a score.
Variations
To show the most uncertain words first, change the loop after reading page:
foreach (var word in page.Words .Where(word => word.Confidence < 0.90f) .OrderBy(word => word.Confidence)) Console.WriteLine(word.Text);
1 0 17
Related recipes
The short answer
After OCR, compare each OcrWord.Confidence to your threshold. Put the recognized text and OcrWord.Box in the review list for words that fall below the cutoff. Keep the page image with the list so a reviewer can check the original pixels rather than trying to infer the intended spelling from the output.
What is a confidence threshold in OCR?
The threshold is your cutoff for review. The OneOcr documentation defines a word’s Confidence as “the calibrated probability that the word is exactly right, calibrated per script on held-out data.” A cutoff of 0.90f flags scores strictly below 90%; it does not mean that 90% of the words on the page are correct. Use Confidence rather than RawConfidence, which is the uncalibrated mean of the best character probabilities.
Compare the unrounded score in code, not the percentage you show to a reviewer. A displayed “90%” can be below the threshold before rounding. Raising the threshold sends more words for review; lowering it sends fewer. Pick a starting threshold on representative pages and check both the flagged words and a sample of words that passed. The tradeoff to measure is how many mistakes you miss versus how much review you create (TDWI’s guide to OCR confidence thresholds).
How do I find low-confidence words on the original image?
Use the same word’s Box, not a text search for its spelling. Two occurrences of “17” can have different boxes and different confidence scores. The page model measures image coordinates from the upper-left corner, with y increasing down the page. Use the original box to focus the reviewer’s attention on a word while keeping its neighbors visible. If you resize the preview, scale the box to match the displayed image rather than drawing it at the original pixel coordinates.
One box is not necessarily the whole value you care about. The blurred bin code in the example comes back as fragments. A reviewer needs the full label and its surroundings to tell whether those fragments should be one field or several.
Is OCR 100% accurate if no words are flagged?
No. Even an empty review list can hide a confidently misread word or text that the recognizer didn’t return at all. For required fields such as a bin code, check that the field is present independently of the confidence check. You can also validate the expected format before accepting it. That catches a different class of problems: a plausible score does not tell you whether a code has the required number of characters.