CV / PPOCR
PPOCR
Detects text polygons, rectifies each region, recognizes the text, and returns coordinates and confidence.
Choose the device you're using, the set up guide and documentation will update accordingly.
Getting Started
sudo docker run --rm --privileged --net=host \
-e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
-v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-ppocr:latest \
python web_service.py --platform rk3576 --model_dir /app/model --host 0.0.0.0 --port 8000REST API
Use the REST API to run inference. Copy the commands below.
curl http://localhost:8080/v1/chat/completions -d '{
"model": "ppocr-rknn",
"messages": [{"role": "user", "content": "Hello"}]
}'import requests
resp = requests.post(
"http://localhost:8080/v1/chat/completions",
json={"model": "ppocr-rknn", "messages": [{"role": "user", "content": "Hello"}]},
)
print(resp.json())Model Details
PPOCR on reComputer RK3576 and RK3588
This end-to-end OCR service comes from
reComputer-RK-CV. It
detects text polygons, sorts them into reading order, perspective-rectifies
each crop, and recognizes every text line.
Model information
| Component | File |
|---|---|
| Text detector | model/ppocr_det.rknn |
| Text recognizer | model/ppocr_rec.rknn |
| Character dictionary | model/ppocr_keys_v1.txt |
| Annotation font | model/simfang.ttf |
| Output | Text, confidence, quadrilateral coordinates, crops, and latency |
PPOCR supports still images only. The upstream service intentionally does not include camera, local-video, or MP4-analysis controls.
Run the service
RK3576
sudo docker run --rm --privileged --net=host \
-e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
-v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-ppocr:latest \
python web_service.py --platform rk3576 --model_dir /app/model \
--host 0.0.0.0 --port 8000RK3588
sudo docker run --rm --privileged --net=host \
-e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
-v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-ppocr:latest \
python web_service.py --platform rk3588 --model_dir /app/model \
--host 0.0.0.0 --port 8000Open http://<BOARD_IP>:8000 or /docs.
Startup arguments
| Argument | Default | Description |
|---|---|---|
--platform | Required | rk3576 or rk3588. |
--model_dir | model | Models, dictionary, font, and sample image. |
--image | None | Still image analyzed before server startup. |
--output | None | Annotated JPG/PNG path for --image. |
--no_server | Off | Exit after processing --image. |
--host / --port | 0.0.0.0 / 8000 | Service address and port. |
To analyze one mounted image, save the annotation, print JSON, and exit:
python web_service.py --platform rk3576 --model_dir model \
--image /data/document.jpg --output /data/document_result.jpg --no_serverREST API
Endpoint: POST /api/models/ppocr/predict
curl -X POST "http://<BOARD_IP>:8000/api/models/ppocr/predict" \
-F "file=@document.jpg" -F "drop_score=0.5" \
-F "include_crops=false"Optional fields are det_threshold, box_threshold, unclip_ratio,
drop_score, max_results, and include_crops. Other endpoints provide
health state, configuration, the latest structured result, the latest annotated
JPEG, and interactive OpenAPI documentation.
| Field | Default | Description |
|---|---|---|
det_threshold | 0.3 | Pixel-map detection threshold from 0 to 1. |
box_threshold | 0.6 | Minimum DB text-box score. |
unclip_ratio | 1.5 | Polygon expansion ratio from 0.1 to 5. |
drop_score | 0.5 | Minimum recognition confidence included in combined text. |
max_results | 100 | Maximum regions sent to recognition. |
include_crops | false | Include base64 JPEG crops in result lines. |
Important response fields:
{
"success": true,
"model": "ppocr",
"result": {
"text": "Recognized first line\nRecognized second line",
"lines": [
{
"index": 1,
"text": "Recognized first line",
"confidence": 0.9621,
"accepted": true,
"box": [[42, 31], [286, 29], [287, 72], [43, 74]]
}
],
"count": 2,
"timing_ms": {"detection": 54.2, "recognition": 71.4, "total": 129.8}
}
}Detection quality directly affects recognition. Very small, blurred, curved,
vertical, low-contrast, or heavily rotated text may be missed, and the simple
reading-order heuristic may not suit complex multi-column documents.
include_crops=true increases the response size and is intended mainly for
the Web results panel. The detector and recognizer are pipeline stages and must
remain compatible with the character dictionary and perspective-crop logic.
Build locally
docker build -f docker/rk3576/ppocr.dockerfile \
-t rk3576-ppocr:local src/rk3576_ppocr
docker build -f docker/rk3588/ppocr.dockerfile \
-t rk3588-ppocr:local src/rk3588_ppocrInputs and Outputs
Input: still image. Output: ordered text lines, confidence scores, quadrilaterals, and annotated image.