ocrmac (Apple Vision) OCR engine for OCR Bridge
Project description
OCR Bridge - ocrmac Engine
ocrbridge-ocrmac is an OCR Bridge engine backed by Apple's Vision framework via ocrmac.
Overview
This package plugs into OCR Bridge through Python entry points and provides HOCR output for images and PDFs on macOS.
Entry point registration (from pyproject.toml):
[project.entry-points."ocrbridge.engines"]
ocrmac = "ocrbridge.engines.ocrmac:OcrmacEngine"
Features
- Native Apple OCR via Vision framework
- LiveText mode support on newer macOS versions
- Input formats: JPEG, PNG, TIFF, PDF
- HOCR XML output with bbox and confidence metadata
- Automatic plugin discovery in OCR Bridge
Platform Requirements
- macOS only (runtime enforces
Darwin) - macOS 10.15+ for Vision modes (
fast,balanced,accurate) - macOS 14.0+ for
livetext
This package will not run on Linux or Windows.
Installation
pip install ocrbridge-ocrmac
Compatibility quick check:
- Python
>=3.10 - macOS
>=10.15(>=14.0forlivetext) - Key runtime deps:
ocrbridge-core>=3.1.0,ocrmac>=0.2.2
Usage
The engine is discovered automatically by OCR Bridge, or you can import and use it directly.
Public API
Stable imports from this package:
OcrmacEngineOcrmacParamsRecognitionLevel
Parameters
languages(list[str] | None): IETF BCP 47 codes (for example"en-US","zh-Hans")recognition_level(RecognitionLevel):fast,balanced,accurate,livetext
Defaults:
languages=None(auto-detect)recognition_level=RecognitionLevel.BALANCED
Example
from pathlib import Path
from ocrbridge.engines.ocrmac import OcrmacEngine, OcrmacParams, RecognitionLevel
engine = OcrmacEngine()
# Process with defaults
hocr = engine.process(Path("document.pdf"))
# Process with custom parameters
params = OcrmacParams(
languages=["en-US", "fr-FR"],
recognition_level=RecognitionLevel.ACCURATE,
)
hocr = engine.process(Path("document.pdf"), params)
# LiveText (requires macOS 14+)
params_livetext = OcrmacParams(
languages=["en-US"],
recognition_level=RecognitionLevel.LIVETEXT,
)
hocr = engine.process(Path("document.pdf"), params_livetext)
Integration (Entry Points)
This package exposes one OCR Bridge engine entry point:
- Group:
ocrbridge.engines - Name:
ocrmac - Target:
ocrbridge.engines.ocrmac:OcrmacEngine
Verify discovery in your environment
If the package is installed but not discovered, run:
from importlib.metadata import entry_points
eps = entry_points()
group = "ocrbridge.engines"
if hasattr(eps, "select"):
engines = eps.select(group=group)
else:
engines = eps.get(group, [])
for ep in engines:
print(f"{ep.name} -> {ep.value}")
Supported Input Formats
.jpg.jpeg.png.pdf.tiff.tif
Development
This repository uses uv for Python environments/dependencies and mise for task aliases.
Setup
mise run install
Quality and Tests
mise run lint
mise run format
mise run typecheck
mise run test
mise run check
mise run all
Direct equivalents:
uv sync --extra dev
uv run ruff check src tests
uv run ruff format src tests
uv run pyright
uv run pytest
Run a Single Test
Use pytest node IDs:
uv run pytest tests/test_models.py::TestOcrmacParams::test_validate_languages
uv run pytest tests/test_engine_unit.py::TestProcessMethod::test_process_routes_to_pdf_handler
Useful filters:
uv run pytest tests/test_engine_integration.py -m integration
uv run pytest -k livetext
Notes on Output and Processing
- Output is HOCR XML (XHTML doctype + namespace)
- OCR annotations are converted from relative bottom-left coordinates to absolute top-left pixel coordinates
- PDFs are rasterized to page images (300 DPI) and merged back into a multi-page HOCR document
Release and CI
- CI runs on macOS and uses
misetasks for lint/format/typecheck/test - Releases are automated with
python-semantic-release - Commit messages follow Conventional Commits (validated in CI)
Troubleshooting
- Engine not discovered: confirm you installed in the active environment, then run the discovery snippet above.
livetextfails: verify macOS major version is 14 or newer.- Non-macOS runtime: expected failure; this engine intentionally supports macOS only.
- PDF OCR issues: ensure Poppler is available when your workflow depends on PDF rasterization tooling.
Contributing
See CONTRIBUTING.md for contribution workflow and commit message guidance.
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 ocrbridge_ocrmac-2.1.0.tar.gz.
File metadata
- Download URL: ocrbridge_ocrmac-2.1.0.tar.gz
- Upload date:
- Size: 2.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fa5cb1200aa8c73a95f6d06dfe199b79e2e32927e9dbc2115726ddcea01c74a
|
|
| MD5 |
54171a730957610ebfaeedbf73681c6b
|
|
| BLAKE2b-256 |
9df56060ea3751ef6f1fc35e3959285082ddad9fa9dfacd86354531ebd5b12ea
|
Provenance
The following attestation bundles were made for ocrbridge_ocrmac-2.1.0.tar.gz:
Publisher:
release.yml on OCRBridge/ocrbridge-ocrmac
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ocrbridge_ocrmac-2.1.0.tar.gz -
Subject digest:
4fa5cb1200aa8c73a95f6d06dfe199b79e2e32927e9dbc2115726ddcea01c74a - Sigstore transparency entry: 928501404
- Sigstore integration time:
-
Permalink:
OCRBridge/ocrbridge-ocrmac@c03c900e7c33d2c63cce05164156a0679802d9f1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/OCRBridge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c03c900e7c33d2c63cce05164156a0679802d9f1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ocrbridge_ocrmac-2.1.0-py3-none-any.whl.
File metadata
- Download URL: ocrbridge_ocrmac-2.1.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9d6487c770ee9a4f6d3dee8644f64aa2720580683186900bb4f4a2128c56480
|
|
| MD5 |
07895467a02db40167cf3371bcecade8
|
|
| BLAKE2b-256 |
ce135886b2f91e185b1cec1d38ac22ab589b4159ddf152bd69d9491231722aab
|
Provenance
The following attestation bundles were made for ocrbridge_ocrmac-2.1.0-py3-none-any.whl:
Publisher:
release.yml on OCRBridge/ocrbridge-ocrmac
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ocrbridge_ocrmac-2.1.0-py3-none-any.whl -
Subject digest:
d9d6487c770ee9a4f6d3dee8644f64aa2720580683186900bb4f4a2128c56480 - Sigstore transparency entry: 928501405
- Sigstore integration time:
-
Permalink:
OCRBridge/ocrbridge-ocrmac@c03c900e7c33d2c63cce05164156a0679802d9f1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/OCRBridge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c03c900e7c33d2c63cce05164156a0679802d9f1 -
Trigger Event:
push
-
Statement type: