Win OCR is a small, local Windows OCR toolkit. It wraps the built-in
Windows.Media.Ocr engine with:
- a tiny .NET CLI (
WinOcrCli) - a Python package (
winocr) for full-image OCR, ROI OCR, batch OCR, and caching
- Windows 10/11
- .NET 8 SDK or newer
- Python 3.9+
- Windows OCR language pack for the language you want to recognize
Install language packs in Windows Settings:
Time & language -> Language & region -> Add a language
cd dotnet\WinOcrCli
dotnet publish -c Release -r win-x64 --self-contained trueThe executable will be created under:
dotnet\WinOcrCli\bin\Release\net8.0\win-x64\WinOcrCli.exe
You can pass that path to Python with --ocr-exe, or copy it to a directory on
your PATH.
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .OCR a full image:
winocr image.png --ocr-exe dotnet\WinOcrCli\bin\Release\net8.0\win-x64\WinOcrCli.exeUse a language tag:
winocr image.png --lang zh-CN --ocr-exe path\to\WinOcrCli.exeOCR a region of interest:
winocr image.png --roi 0,0,1200,300 --ocr-exe path\to\WinOcrCli.exeBatch OCR all images in a folder:
winocr .\screenshots --glob "*.png" --jsonl output\ocr.jsonl --ocr-exe path\to\WinOcrCli.exeUse from Python:
from winocr import WinOcrEngine
engine = WinOcrEngine(ocr_exe=r"path\to\WinOcrCli.exe")
text = engine.ocr_image(r"C:\path\to\image.png", lang="en-US")
print(text)- This is local OCR: images are sent only to the Windows OCR runtime.
- ROI values are
x,y,width,heightin pixels. - OCR results are cached by image hash, ROI, and language in
.winocr-cache/.
MIT