CV / LPRNet

LPRNet

RKNN recognizes cropped Chinese plates with a PP-OCR fallback, while the Hailo pipeline combines Tiny-YOLOv4 plate detection with LPRNet numeric OCR.

15 downloads
Precision
RKNN / Hailo HEF

Choose the device you're using, the set up guide and documentation will update accordingly.

Getting Started

Deploy
sudo docker run --rm --privileged --net=host \
  -e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
  --device /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-lprnet:latest \
  python web_service.py --platform rk3576 --model_dir /app/model --camera_id -1 --host 0.0.0.0 --port 8000

REST API

Use the REST API to run inference. Copy the commands below.

Curl
curl http://localhost:8080/v1/chat/completions -d '{
  "model": "lprnet-rknn",
  "messages": [{"role": "user", "content": "Hello"}]
}'
Python
import requests

resp = requests.post(
    "http://localhost:8080/v1/chat/completions",
    json={"model": "lprnet-rknn", "messages": [{"role": "user", "content": "Hello"}]},
)
print(resp.json())

Model Details

reComputer RK

LPRNet on reComputer RK3576 and RK3588

This service is based on the LPRNet module in reComputer-RK-CV. It recognizes Chinese colored plates with LPRNet and can route light or international plates to the bundled PP-OCR recognizer.

Model information

ComponentFile
Chinese plate recognizermodel/lprnet.rknn
International/light plate fallbackmodel/ppocr_rec.rknn
PP-OCR dictionarymodel/ppocr_keys_v1.txt
OutputPlate text, recognizer, scores, box, and rejection information

The Web UI provides a four-point selection tool. The selected quadrilateral is perspective-rectified before recognition.

Run the service

RK3576

bash
sudo docker run --rm --privileged --net=host \
  -e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
  --device /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-lprnet:latest \
  python web_service.py --platform rk3576 --model_dir /app/model \
  --camera_id -1 --host 0.0.0.0 --port 8000

RK3588

bash
sudo docker run --rm --privileged --net=host \
  -e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
  --device /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-lprnet:latest \
  python web_service.py --platform rk3588 --model_dir /app/model \
  --camera_id -1 --host 0.0.0.0 --port 8000

Open http://<BOARD_IP>:8000 or /docs. Camera IDs map to /dev/videoN. Local-video mode accepts --video or --video_path and takes precedence over the camera.

Startup arguments

ArgumentDefaultDescription
--platformRequiredrk3576 or rk3588.
--model_dirmodelBoth recognizers, dictionary, and warm-up image.
--camera_id-1Camera index; -1 enables uploads only.
--video, --video_pathNoneLooping local MP4; overrides the camera.
--host / --port0.0.0.0 / 8000Service address and port.

The Web four-point selector allows each corner to move independently. The selected quadrilateral is perspective-corrected and recognized as one plate.

REST API

Endpoint: POST /api/models/lprnet/predict

bash
curl -X POST "http://<BOARD_IP>:8000/api/models/lprnet/predict" \
  -F "file=@plate.jpg" -F "whole_image=true" \
  -F "plate_layout=auto"

Important fields include manual_quad, manual_box, plate_layout, min_score, max_plates, and min_text_length. plate_layout=auto selects LPRNet for Chinese colored plates and PP-OCR for light/international plates.

manual_quad is a JSON array of four source-image points. manual_box is [x1,y1,x2,y2] and bypasses automatic localization. whole_image=true marks an already cropped plate. min_score is useful for relative filtering but is not a calibrated probability.

Example response:

json
{
  "success": true,
  "model": "lprnet",
  "result": {
    "plates": [
      {
        "text": "京A12345",
        "recognition_score": 0.91,
        "candidate_score": 1.0,
        "recognizer": "lprnet",
        "box": [0, 0, 94, 24]
      }
    ],
    "count": 1,
    "source_mode": "plate_crop"
  }
}

GET/POST /api/config manages min_score, max_plates, min_text_length, and plate_layout. Other endpoints include GET /api/results/latest, MJPEG, MP4 upload, analysis, progress, list, and download.

Scope and limitations

Neither bundled recognizer is an end-to-end plate detector. Uploaded scene images should use the four-point tool or manual_quad. Local-video frames are treated as already-cropped plates, while camera scene boxes rely on lightweight OpenCV heuristics. Production scene deployments should add a dedicated plate detector. The service ranks bright plate candidates ahead of traffic lights and tail lights, but these image-processing heuristics are not a substitute for a trained detector.

Build locally

bash
docker build -f docker/rk3576/lprnet.dockerfile \
  -t rk3576-lprnet:local src/rk3576_lprnet

docker build -f docker/rk3588/lprnet.dockerfile \
  -t rk3588-lprnet:local src/rk3588_lprnet

Inputs and Outputs

RKNN: cropped plate or selected region to recognized text. Hailo: traffic frame to detected plate box and CTC-decoded numeric plate text.