dotnet add package RecursiveAI.OneOcr dotnet add package RecursiveAI.OneOcr.Models.Hebrew
Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneImage; using OneOcr; var engine = OcrEngine.LoadBundled(); var image = Image.Load("notice.png"); var options = new OcrOptions { Languages = ["he"] }; var text = image.ToText(engine, options); Console.WriteLine(text);
Paste the code above into Program.cs of a new dotnet new console project and dotnet run, or unzip the example and dotnet run.
The printed text in notice.png (included in the zip):
החנות פתוחה היום נא לסגור את הדלת
What the example prints:
החנות פתוחה היום נא לסגור את הדלת
The he hint selects the Hebrew recognizer. If RecursiveAI.OneOcr.Models.Hebrew isn’t installed, this example prints a blank line.
The page API (image.Ocr) reports why as diagnostic OCR114.
Variations
Save the Hebrew text as UTF-8. Replace the print call with:
File.WriteAllText("hebrew.txt", text);Related recipes
The short answer
Install RecursiveAI.OneOcr.Models.Hebrew alongside RecursiveAI.OneOcr. Load the image and pass it to ToText with a bundled engine. Use Languages = ["he"] for a Hebrew-only image. The model is for unpointed Hebrew: don’t use it to transcribe niqqud, the dots and other marks that indicate vowels.
How do you convert a Hebrew photo to editable text?
The same call works with a photo in place of the PNG. Start with an upright, tightly framed image of the printed text. OneOcr can straighten tilted text by default, but the reported angle is an estimate, not a measurement of how the camera was held. Check the image and the result before treating the angle as a reason to rotate or reject a scan.
OCR returns Hebrew as text you can copy or save. It doesn’t translate that text to English. Use the hebrew.txt variation if your terminal displays the words poorly. An editor with Hebrew font and bidirectional text support can display the file even if the terminal cannot. If you need word positions as well as text, the word-box recipe shows how to read the structured result instead.
Does Hebrew OCR preserve right-to-left reading order?
OneOcr returns right-to-left lines in logical order. Hebrew letters are stored as you would type them, even though the display puts the first letter on the right. The Unicode Bidirectional Algorithm describes how a renderer lays out that text alongside left-to-right digits and words. Set the base direction to right-to-left when showing a Hebrew paragraph in an app; don’t reverse the stored string. Reversing the characters to make a particular console look right would change the text you save or search.