Crates.io | macocr |
lib.rs | macocr |
version | 0.4.5 |
created_at | 2025-07-31 15:15:50.184889+00 |
updated_at | 2025-09-18 13:02:42.844516+00 |
description | An OCR Tool using Apple's Vision Framework API. |
homepage | |
repository | https://github.com/riddleling/macocr |
max_upload_size | |
id | 1775206 |
size | 83,595 |
An OCR Tool using Apple's Vision Framework API.
OCR Tool using Vision Framework API
Usage: macocr [OPTIONS] [FILES]...
Arguments:
[FILES]... Input files
Options:
-o, --ocr OCR and export text files
-s, --server Run HTTP Server
-a, --auth <AUTH> HTTP Basic Auth (username:password) [default: ]
-p, --port <PORT> HTTP port number [default: 8000]
-h, --help Print help
-V, --version Print version
macocr -o *.png
macocr -s -p 80
macocr -s -a admin:password123 -p 80
After starting the HTTP server, you can upload an image from the homepage HTML or use curl
to send an image via the upload
API:
curl -u admin:password123 \
-H "Accept: application/json" \
-X POST http://localhost:80/upload \
-F "file=@01.png"
The JSON response looks like this:
{
"success": true,
"message": "File uploaded successfully",
"ocr_result": "Hello\nWorld\n",
"image_width": 1247,
"image_height": 648,
"ocr_boxes": [
{
"text": "Hello",
"x": 434.7201472051599,
"y": 269.3123034733379,
"w": 216.30970547749456,
"h": 69.04344177246088
},
{
"text": "World",
"x": 429.5100030105896,
"y": 420.4043957924413,
"w": 242.85499225518635,
"h": 73.382080078125
}
]
}
image_width
and image_height
represent the width and height of the image (in px),
x
and y
represent the top-left origin of the text bounding box (in px),
w
and h
represent the width and height of the text bounding box (in px).
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install macocr
cargo install macocr
macocr -h
macOS users need to perform batch OCR processing
Applications that need to integrate OCR functionality via API
MIT License