Cross-platform screenshot & clipboard OCR with bbox, powered by RapidOCR.
Project description
clipocr
Cross-platform screenshot & clipboard OCR for Python. Powered by RapidOCR. Returns text plus bounding boxes. Works on macOS / Windows / Linux.
Why
You took a screenshot. You want the text out of it — without uploading it anywhere.
clipocr reads the image directly from your clipboard or a file, runs a fast on-device OCR model, and gives you back:
- the recognized text (in reading order),
- a list of
Blocks, each withtext,bbox(xmin, ymin, xmax, ymax) andconfidence, - and overall metadata (engine, image size, average confidence).
Good for: error-screenshot to text, code screenshots, UI mock review, document snippets, anything where you don't want to send your image to a cloud API.
Install
pip install clipocr
The first run downloads ~15 MB of ONNX models into your site-packages (one-time, then cached).
Quick start
Python
from clipocr import ocr, ocr_clipboard
# From a file path
result = ocr("screenshot.png")
print(result.text)
for block in result.blocks:
print(block.bbox, block.text, block.confidence)
# From the system clipboard
result = ocr_clipboard()
print(result.text)
OcrResult is a frozen dataclass:
result.text # str — full text in reading order, joined by "\n"
result.blocks # list[Block] — text + bbox + confidence per region
result.confidence # float — average confidence, 0..1
result.engine # "rapidocr"
result.image_size # (width, height)
result.is_empty # True when no text was found
result.to_dict() # JSON-serializable dict
CLI
clipocr screenshot.png # plain text
clipocr screenshot.png --bbox # text with bounding boxes
clipocr screenshot.png --json # full result as JSON
clipocr --clip # read image from clipboard
clipocr --version
Set CLIPOCR_VERBOSE=1 to keep RapidOCR's INFO logs visible.
Platform notes
| Platform | Clipboard backend |
|---|---|
| macOS | Pillow ImageGrab.grabclipboard() |
| Windows | Pillow ImageGrab.grabclipboard() |
| Linux (Wayland) | wl-paste --type image/png |
| Linux (X11) | xclip -selection clipboard -t image/png -o |
On Linux, install wl-clipboard (Wayland) or xclip (X11) to enable --clip.
Languages
clipocr ships with the default RapidOCR PP-OCRv4 mobile models. They handle:
- Simplified & Traditional Chinese
- English (Latin alphabet)
- Numbers and common punctuation
Mixed Chinese + English content works out of the box.
Development
git clone https://github.com/lidongyangLeo/clipocr.git
cd clipocr
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest # unit tests with coverage
pytest -m integration # also exercise the real RapidOCR engine
ruff check src tests # lint
The test suite enforces ≥ 90% coverage via pytest-cov.
How it works
┌──────────────────┐ ┌─────────────┐ ┌──────────┐
│ image / clipboard │ --> │ RapidOCR │ --> │ OcrResult │
└──────────────────┘ │ (ONNX, on-device) │ └──────────┘
└─────────────┘
clipocr is a thin shim around RapidOCR. It contributes:
- A clean Python API (
ocr/ocr_clipboard/OcrResult). - A cross-platform clipboard adapter.
- Reading-order block sorting (top-to-bottom rows, left-to-right within a row).
- A version-tolerant engine output normalizer (works with both legacy
rapidocr-onnxruntimeand the newrapidocr>= 2.x). - A
clipocrCLI with stdout-clean defaults.
Contributing
Issues and PRs welcome. Please run the tests and ruff check before submitting.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clipocr-0.1.0.tar.gz.
File metadata
- Download URL: clipocr-0.1.0.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd62a51392f88c8fc740be57e88aa5c532779a19d95e5b5b11ec750fe9c1ff9b
|
|
| MD5 |
80a58a313ac2eceb7faed533effd85de
|
|
| BLAKE2b-256 |
e3c81cd8cafa9f77730b8ee3baba2357291fa0935044ad00f656e2057efc2674
|
Provenance
The following attestation bundles were made for clipocr-0.1.0.tar.gz:
Publisher:
publish.yml on lidongyangLeo/clipocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clipocr-0.1.0.tar.gz -
Subject digest:
dd62a51392f88c8fc740be57e88aa5c532779a19d95e5b5b11ec750fe9c1ff9b - Sigstore transparency entry: 1559954262
- Sigstore integration time:
-
Permalink:
lidongyangLeo/clipocr@3f320911f2fb8b00ddf30dcf453b516bcda469e8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/lidongyangLeo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3f320911f2fb8b00ddf30dcf453b516bcda469e8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file clipocr-0.1.0-py3-none-any.whl.
File metadata
- Download URL: clipocr-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ebb8ecc54e5647f45381fd1c80cfbe97e3bb2d9efd638ff478c7b914e7f4c6a
|
|
| MD5 |
8c794a4851b95e4a061c979b42503da3
|
|
| BLAKE2b-256 |
82840cf96ac406ccc75bc268857c43ab70504768a2b6c25022646a6c073310f6
|
Provenance
The following attestation bundles were made for clipocr-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on lidongyangLeo/clipocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clipocr-0.1.0-py3-none-any.whl -
Subject digest:
9ebb8ecc54e5647f45381fd1c80cfbe97e3bb2d9efd638ff478c7b914e7f4c6a - Sigstore transparency entry: 1559954382
- Sigstore integration time:
-
Permalink:
lidongyangLeo/clipocr@3f320911f2fb8b00ddf30dcf453b516bcda469e8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/lidongyangLeo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3f320911f2fb8b00ddf30dcf453b516bcda469e8 -
Trigger Event:
release
-
Statement type: