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.06437717378139496, 'lines': [{'text': '(Press CTRL+C to quit)', 'bounding_rect': {'x1': 13.0, 'y1': 38.0, 'x2': 458.0, 'y2': 38.0, 'x3': 458.0, 'y3': 77.0, 'x4': 13.0, 'y4': 76.0}, 'words': [{'text': '(Press', 'bounding_rect': {'x1': 14.353108406066895, 'y1': 39.69878387451172, 'x2': 140.3456573486328, 'y2': 41.31085205078125, 'x3': 139.93304443359375, 'y3': 73.41635131835938, 'x4': 13.778392791748047, 'y4': 74.0859375}, 'confidence': 0.9870722889900208}, {'text': 'CTRL+C', 'bounding_rect': {'x1': 155.53341674804688, 'y1': 41.37630844116211, 'x2': 273.66094970703125, 'y2': 41.40755081176758, 'x3': 273.42254638671875, 'y3': 74.35794830322266, 'x4': 155.1415557861328, 'y4': 73.46490478515625}, 'confidence': 0.9822005033493042}, {'text': 'to', 'bounding_rect': {'x1': 298.973388671875, 'y1': 41.21086502075195, 'x2': 334.41058349609375, 'y2': 40.91863250732422, 'x3': 334.25103759765625, 'y3': 75.33767700195312, 'x4': 298.7672424316406, 'y4': 74.74362182617188}, 'confidence': 0.9981738328933716}, {'text': 'quit)', 'bounding_rect': {'x1': 357.4715881347656, 'y1': 40.60407257080078, 'x2': 459.0, 'y2': 38.89320755004883, 'x3': 459.0, 'y3': 78.0, 'x4': 357.3414306640625, 'y4': 75.82363891601562}, 'confidence': 0.9932758808135986}]}]}

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.12.tar.gz (6.4 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.12-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for oneocr-1.0.12.tar.gz
Algorithm Hash digest
SHA256 a043d77739d0836dfb1cc2d8b17fa20c822108394176c60fedd4e842a409ef9e
MD5 3f64c747b506997bd85a90454ecaba9f
BLAKE2b-256 eabfd30c7a640b2e95074ccbc05e55f8bda1dc8e65c11c65732435547f880c2c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for oneocr-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 0c0bedbb44f59f6a2b4579b4ec931a83aaab18dd714cb5cd41a7bd9c85a2acf0
MD5 555b2c9527728d1d27fe6f567fd0dcab
BLAKE2b-256 ad97855c742e134ca54a5f304d198b4eb6b54ce91b7c6c3f1f83bb9e38d328de

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