Stop OCR cleanup from changing letter O to zero in IDs. Try identifiers.png from the zip.
dotnet add package RecursiveAI.OneOcrRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneImage; using OneOcr; var engine = OcrEngine.LoadBundled(); var image = Image.Load("identifiers.png"); var page = image.Ocr(engine, new OcrOptions { FixDigitLookalikes = false, FixSeparators = false }); Console.WriteLine(page.ToText());
Unzip the example, then dotnet run.
Prints the recognized text with digit-lookalike and separator correction turned off:
ACC-71O3O5 · LOT-2048 I SHIP-4O16 | BIN-38 2020-04-O7
With corrections off, ACC-71O3O5 has capital O’s at positions 3 and 5 after the hyphen. The standalone I is a recognition error: it isn’t in the image.
using OneImage; imports Image from RecursiveAI.OneImage, which RecursiveAI.OneOcr installs as a dependency.
The full program
The generated image contains this text. The round characters in 71O3O5, 4O16 and O7 are capital O’s.
ACC-71O3O5 · LOT-2048 SHIP-4O16 | BIN-38 2020-04-O7
The program reads the same image twice with the bundled engine and prints the settings and page diagnostics for both runs.
using OneImage; using OneOcr; var engine = OcrEngine.LoadBundled(); var image = Image.Load("identifiers.png"); foreach (bool fix in new[] { true, false }) { var options = new OcrOptions { FixDigitLookalikes = fix, FixSeparators = fix }; var page = image.Ocr(engine, options); Console.WriteLine($"FixDigitLookalikes={fix}, FixSeparators={fix}"); Console.WriteLine(page.ToText()); Console.WriteLine($"Diagnostics: {page.Diagnostics.Count}"); foreach (var note in page.Diagnostics) Console.WriteLine($"{note.Code}: {note.Message}"); }
dotnet run prints:
FixDigitLookalikes=True, FixSeparators=True ACC-710305 · LOT-2048 I SHIP-4016 | BIN-38 2020-04-07 Diagnostics: 1 OCR101: UnitsPerInch is estimated at 200 from the size of the text; pass OcrOptions.Dpi to set it. FixDigitLookalikes=False, FixSeparators=False ACC-71O3O5 · LOT-2048 I SHIP-4O16 | BIN-38 2020-04-O7 Diagnostics: 1 OCR101: UnitsPerInch is estimated at 200 from the size of the text; pass OcrOptions.Dpi to set it.
With corrections on, ACC-710305 has zeros at positions 3 and 5 after the hyphen. With corrections off, ACC-71O3O5 has capital O’s in those positions. The digit rule changed three tokens in this run; the middle dot and vertical bar were read the same way in both runs. OCR101 reports an estimated image resolution, not which characters changed. If a file can’t be decoded, OneOcr throws OcrFormatException; an incorrect character in a valid image doesn’t have to raise an error or a diagnostic.
Variations
Disable accent cleanup as well. Replace the options in the snippet at the top if accents or dots are meaningful parts of your identifiers.
var options = new OcrOptions { FixDigitLookalikes = false, FixSeparators = false, FixStrayAccents = false }; Console.WriteLine(image.Ocr(engine, options).ToText());
Related recipes
The short answer
Set FixDigitLookalikes = false and FixSeparators = false on the OcrOptions passed to Ocr. This prevents those two rules from changing the recognizer’s characters. It doesn’t make a wrong recognition right: if the OCR model already read a letter as a digit, turning off a later rewrite won’t restore the letter. The variation also disables stray-accent cleanup.
Why does OCR read the letter O as zero in identifiers?
There are two places it can happen. The model can mistake the shapes for each other, or OneOcr’s digit rule can rewrite what the model read. The option’s documentation describes the latter: a word with at least three digits can have its O changed to 0 in a run made entirely of digits and capital Os. It doesn’t touch CO2 or short O2. A rule that helps with dates can be wrong for a serial number that legally contains letters in the same positions as digits. In the sample, 2020-04-07 is plausible as a date but is not what the image literally says.
Does turning off character correction improve OCR accuracy?
No. It only stops the rewrite rules; it can’t fix a letter the recognizer misread. Compare the output against the known source or the formats your identifiers allow. If a field admits only digits, log or flag a suspicious letter for review; if both characters are valid, don’t normalize them globally. The separator rule handles single marks between words, not hyphens inside a code. Word spacing and noise removal are separate options, so turning off the two rules does not freeze whitespace or keep every speck read as a word. Compare text and diagnostics from both runs: the diagnostics can explain page-level conditions, but the text comparison tells you whether a particular identifier changed.