CV / PPOCR
PPOCR
End-to-end text detection and recognition using RKNN PPOCR-Det and PPOCR-Rec.
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
Quick Start
1. Install Docker
Run the following commands on the development board to install Docker:
# Download installation script
curl -fsSL https://get.docker.com -o get-docker.sh
# Install using Aliyun mirror source
sudo sh get-docker.sh --mirror Aliyun
# Start Docker and enable auto-start on boot
sudo systemctl enable docker
sudo systemctl start docker2. Run the Project (One command, dual-mode preview)
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.
Step A: Pull Images
sudo docker pull ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-ppocr:latest
sudo docker pull ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-ppocr:latestStep B: Run with One Click
For 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 8000For RK3588:
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.
🔌 API Documentation
1. OCR Interface (Predict)
Endpoint: POST /api/models/ppocr/predict
Request Parameters (Multipart/Form-Data):
| Field | Required | Default | Description |
|---|---|---|---|
file | Yes | — | JPG, PNG, BMP, or WEBP image. |
det_threshold | No | 0.3 | Pixel-map detection threshold from 0 to 1. |
box_threshold | No | 0.6 | Minimum DB text-box score. |
unclip_ratio | No | 1.5 | Polygon expansion ratio from 0.1 to 5. |
drop_score | No | 0.5 | Minimum recognition confidence included in combined text. |
max_results | No | 100 | Maximum regions sent to recognition. |
include_crops | No | false | Include base64 JPEG crops in result lines. |
Usage Examples:
curl -X POST "http://<BOARD_IP>:8000/api/models/ppocr/predict" \
-F "file=@document.jpg" -F "drop_score=0.5" \
-F "include_crops=false"Response Format (JSON):
{
"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}
}
}2. System Configuration Interface (Config)
GET /api/config: Returns the current detection and recognition defaults.POST /api/config: Updates any supported threshold or result-limit field.
Other endpoints provide health state, the latest structured result, the latest
annotated JPEG, and interactive OpenAPI documentation at /docs.
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.
3. Command Line 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_server🛠️ Developer Guide (Production Recommendations)
Build Local Images
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.