ocr-locator
A tiny Python package that wraps a full PaddleOCR workflow — engine setup, text/number/symbol extraction, bounding-box drawing, and word search — behind a single class or one CLI command, so you don't have to re-copy notebook cells every time.
Install
pip install ocr-locator
(Or, from a local checkout: pip install .)
First run downloads PaddleOCR's model weights automatically — no manual setup needed.
Usage
Python API
from ocr_locator import OCRLocator
ocr = OCRLocator() # loads the PaddleOCR engine once (put outside any loop)
# 1. Extract all text/numbers/symbols with boxes
extracted = ocr.extract("screenshot.png")
# -> [{"text": "Login", "score": 0.98, "box": [120, 40, 210, 70]}, ...]
# 2. Draw a box + label around every detection
annotated_path = ocr.annotate("screenshot.png", extracted, output_path="out.png")
# 3. Search for a word/phrase; matches are highlighted in a separate image
result = ocr.search("screenshot.png", extracted, "Login")
result["found"] # True/False
result["matches"] # matching detection dicts
result["annotated_path"] # path to the highlighted image, if found
Command line
Runs the whole workflow — extract, annotate, search — in one shot:
ocr-locate screenshot.png --search "Login" --output detected.png --json-output detections.json
Omit --search and you'll be prompted interactively; pass --no-prompt to
skip search entirely and just get the all-boxes annotated image.
What it handles for you
- Dependency management —
paddlepaddle,paddleocr,paddlex, andPillowdeclared inpyproject.toml. - Engine initialization —
PaddleOCR(...)created once perOCRLocatorinstance, withenable_mkldnn=Falseset by default to avoid a known oneDNN runtime crash. - Box normalization — handles rectangles, 4-point polygons, and flattened 8-number quads, whatever shape PaddleOCR returns.
- Drawing — labeled bounding boxes for every detection, with separate colors for "all detections" vs. "search matches".
- Search — case-insensitive substring or exact match, with match details printed and a highlighted image saved automatically.
Package layout
ocr_locator/
├── __init__.py # public API: OCRLocator
├── config.py # default confidence, colors, font, PaddleOCR init kwargs
├── core.py # OCRLocator class: extract(), annotate(), search()
├── utils.py # to_rect() box-shape normalizer
└── cli.py # `ocr-locate` command line entry point
Notes
- Unlike the original notebook, this package does not force an interactive Colab file upload/download — you pass a file path in and get a file path out, so it works the same in a script, a notebook, or a server.
ocr.extract()is a pure function-ish call you can run once and reuse for bothannotate()and multiplesearch()calls without re-running OCR.
Release files for ocr-locator 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ocr_locator-0.1.0.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ocr_locator-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.1 kB
Release files / ocr_locator-0.1.0.tar.gz
| Download URL | ocr_locator-0.1.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56034dbb9f38d5ad365f94c5856b5e8f95ea378e0ecda62084b88b5d2fb419fa
|
|
BLAKE2b-256 checksum How to use checksums |
9487ac1c572cef5867cc5c7bccf257f6a6a0ffe65f3eeff2ad92dfd9060bd912
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|
Release files / ocr_locator-0.1.0-py3-none-any.whl
| Download URL | ocr_locator-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7cba25daad8bc356b0ed041e2cb7212175a6d613a735422b93028db7dac4331
|
|
BLAKE2b-256 checksum How to use checksums |
3a68108d32b8179b342897ea3156c66de10ac09ae20d45d3410135f1544ee3c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|