Skip to main content

Snipping Tool OCR for Windows

Project description

Originally from: https://b1tg.github.io/post/win11-oneocr/ and https://github.com/Cecilia-pj/win11_oneocr_py. Webserver code from https://github.com/GitHub30/winocr . Basic library which returns a dict with the text, text angle, lines, and words in each line (with text, bounding boxes and confidence values for each word) using the Snipping Tool OCR on Windows. It also includes a small web server to serve OCR requests, as inspired by WinOCR.

To use you need to place 3 files from recent Windows 11 versions of Snipping Tool. The easiest way to get them is through https://store.rg-adguard.net, insert "https://apps.microsoft.com/detail/9mz95kl8mr0l" in the search box and download the most recent "Microsoft.ScreenSketch" "msixbundle" file. Then rename it to .zip and extract it. Extract the "SnippingToolApp" "msix" file for your architecture (x64 or ARM64) again after also renaming it to .zip, and the files should be in the "SnippingTool" folder.

  • oneocr.dll
  • oneocr.onemodel
  • onnxruntime.dll

These files should be placed in the C:/Users/your_user_folder/.config/oneocr folder.

Usage is similar to WinOCR:

from PIL import Image
import oneocr

img = Image.open('test.jpg')
model = oneocr.OcrEngine()
model.recognize_pil(img)['text']
import requests

bytes = open('test.jpg', 'rb').read()
requests.post('http://localhost:8001/', bytes).json()['text']
import cv2
import oneocr

img = cv2.imread('test.jpg')
model = oneocr.OcrEngine()
model.recognize_cv2(img)['text']

To run the server:

pip install oneocr[api]
oneocr_serve

The returned dict looks like this:

{'text': '(Press CTRL+C to quit)', 'text_angle': 0.1287536919116974, 'lines': [{'text': '(Press CTRL+C to quit)', 'bounding_rect': {'x1': 15.0, 'y1': 55.0, 'x2': 460.0, 'y2': 55.0}, 'words': [{'text': '(Press', 'bounding_rect': {'x1': 16.31104850769043, 'y1': 56.61604309082031, 'x2': 144.23599243164062, 'y2': 58.337398529052734}, 'confidence': 0.9861753582954407}, {'text': 'CTRL+C', 'bounding_rect': {'x1': 158.8894805908203, 'y1': 58.3936767578125, 'x2': 278.3717956542969, 'y2': 58.33317565917969}, 'confidence': 0.9664466381072998}, {'text': 'to', 'bounding_rect': {'x1': 301.47845458984375, 'y1': 58.12306213378906, 'x2': 339.2376403808594, 'y2': 57.741416931152344}, 'confidence': 0.9981067776679993}, {'text': 'quit)', 'bounding_rect': {'x1': 362.3424377441406, 'y1': 57.38189697265625, 'x2': 461.0, 'y2': 55.520843505859375}, 'confidence': 0.9936797022819519}]}]}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oneocr-1.0.5.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oneocr-1.0.5-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file oneocr-1.0.5.tar.gz.

File metadata

  • Download URL: oneocr-1.0.5.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for oneocr-1.0.5.tar.gz
Algorithm Hash digest
SHA256 53b5f086ecd9e63ff6474e78c0d76e7a305d099d4174af5743159ad1af7a2b3f
MD5 b0fcb759ee99bbbce1397f9eec8a0837
BLAKE2b-256 dd2fbc7e426dee8534f75a9ddd193e683f6fad2c991668d66b3f74d0b5810a04

See more details on using hashes here.

File details

Details for the file oneocr-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: oneocr-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for oneocr-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d564e46b5f2d11e75c4951ef9bfde285dfa077f7c2066b33543281efabac2f3e
MD5 0115903dbb9f2fbf0b4a5cb489b9a68e
BLAKE2b-256 048ac0543e8fe2847ed36b9a959d47aaa530a5c3bab3cc25410f1380e5623855

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page