Application Test - Text Detection and Recognition (PP-OCR)

Run Talowe
talowe_ppocr_camon CAM126B-P: the camera performs real-time text region detection + content recognition (two RKNN models, PP-OCRv4 det / rec), draws quadrilateral boxes, and pushes H.264 RTP to the computer. Openppocr.sdpin VLC to view the picture.Source: https://github.com/hbt021211-coder/talowe-rv1126b-aidemo
Inference: RKNN | Capture: V4L2
/dev/video12NV12 1920x1080| Encoding: MPP | Stream receive: UDP5000
Talowe's original project uses OpenCV + GStreamer. The factory Buildroot IPC does not have GStreamer / system OpenCV.
Capture and encoding in the current Demo have been changed to V4L2 + RGA + MPP; the detection post-processing (contours / perspective cropping) still links against the OpenCV 3.4 static library bundled in the project (opencv-linux-aarch64), so you do not need to install OpenCV on the board.
Encoding uses a direct NV12 copy from the camera, and boxes are drawn on NV12, avoiding RGB→NV12 causing VLC to be all black.
The procedure on this page is written for rkipc, /dev/video12, S99rkipc).
- For flashing, see CAM126B-P Buildroot IPC (
Rockchip-RV1126B-Buildroot-IPC) in Upgrade Firmware Reflashing is not required : if the board already has this IPC firmware, demonstrate directly- If it is currently Debian / another image, first flash Buildroot IPC according to that page, then follow the steps below
For IPC streaming, account and password, see Firmware Usage - IPC Streaming.
This Demo shares camera /dev/video12 and UDP 5000 with Human Pose, YOLOv5, YOLO26, YOLO11, and Facial Features, and cannot run simultaneously.
run_ppocr.sh stops the other Demos / rkipc first.
Demonstration (see the effect directly)
Environment as the three machines below. If the computer IP is not 10.0.0.49, change the script parameter to your IP.
| Role | Address | Description |
|---|---|---|
| Stream-receiving computer (Mac) | 10.0.0.49 | Install VLC, open ppocr.sdp |
| CAM126B-P | ssh root@10.0.2.0 | Default password see Firmware Usage |
| Program directory | /root/rknn_ppocr_cam | Already deployed package |
1. Open VLC on the computer first
Copy ppocr.sdp to the computer, e.g. ~/ppocr.sdp. The content is fixed as follows (port 5000, do not change to the board IP):
v=0
o=- 0 0 IN IP4 0.0.0.0
s=PPOCR
c=IN IP4 0.0.0.0
t=0 0
m=video 5000 RTP/AVP 96
a=rtpmap:96 H264/90000
The package also contains a play.sdp with the same content (s=PPOCR). For this page use ppocr.sdp; do not mix it with the pose / YOLO sdp.
open -a VLC ~/ppocr.sdp
Or VLC → File → Open File → select ppocr.sdp.
The first time it may ask the local firewall to allow UDP 5000; click Allow.
VLC will stay black waiting for the stream; this is normal. Start the board side in the next step.
2. Start streaming on the board
ssh root@10.0.2.0
cd /root/rknn_ppocr_cam
./run_ppocr.sh 10.0.0.49
run_ppocr.sh will: stop other Demos / rkipc → open /dev/video12 → detect + recognize → push H.264 to 10.0.0.49:5000.
When you see logs like the following, the stream is out:
v4l2 opened /dev/video12 1920x1080 stride=1920 nbufs=4
mpp rtp -> 10.0.0.49:5000 1920x1080
Pipeline initialized. Starting inference, RTP 10.0.0.49:5000 ...
[OCR] text: Hello score: 0.97 quad:(412,201)(890,198)(888,260)(410,263)
VLC should show a live picture: quadrilateral text region boxes and FPS in the upper-left corner. English is overlaid next to the boxes; for Chinese overlay text the English bitmap font is used, so the picture may only show the score — for the full recognition result, see the serial [OCR] log. Point the camera at paper labels, screen text, or nameplates.
Manual equivalent command (when not using the script):
/etc/init.d/S99rkipc stop
cd /root/rknn_ppocr_cam
export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
./rknn_ppocr_cam ./model/ppocrv4_det.rknn ./model/ppocrv4_rec.rknn /dev/video12 10.0.0.49
The fourth parameter must be the 10.0.2.0.
3. After the demonstration, restore IPC
After stopping the Demo with Ctrl + C:
killall rknn_ppocr_cam rkaiq_3A_server 2>/dev/null
/etc/init.d/S99rkipc start
The web page / RTSP (rtsp://10.0.2.0:554/live/0) will recover.
The Demo and rkipc cannot occupy the camera at the same time.
Board-side package contents
root@rv1126bp-buildroot:~/rknn_ppocr_cam# ls
lib model play.sdp ppocr.sdp rknn_ppocr_cam run_ppocr.sh
| File | Purpose |
|---|---|
rknn_ppocr_cam | Main program (detection + recognition) |
run_ppocr.sh | Stop rkipc and start; parameter is the computer IP |
ppocr.sdp | Copy to the computer for VLC (recommended) |
play.sdp | Same content as ppocr.sdp, s=PPOCR |
model/ppocrv4_det.rknn | Text detection model (about 2.5 MB) |
model/ppocrv4_rec.rknn | Text recognition model (about 6.9 MB) |
model/ppocr_keys_v1.txt | Character table backup (the recognition dictionary is compiled into dict.h) |
lib/librknnrt.so librga.so librockchip_mpp.so | NPU / RGA / encoding |
Startup parameters:
./rknn_ppocr_cam <det_model> <rec_model> <camera_index> <target_ipv4>
<camera_index>: ISP main path; on this board it is/dev/video12(rkisp_mainpathinv4l2-ctl --list-devices)<target_ipv4>: LAN IP of the stream-receiving computer; port is hardcoded 5000
Detection thresholds are in main.cc: threshold 0.3, box_threshold 0.6, db_unclip_ratio 1.5. Recognition results below TEXT_SCORE (ppocr_system.h, default 0.5) are discarded.
Compile from source and deploy
You can skip this section if you only want to demonstrate. Follow the steps below when changing code or changing boards.
Machines
| Role | Example |
|---|---|
| Local machine | ~/SDK/talowe-rv1126b-aidemo (Mac only edits code and rsyncs) |
| Build server | ssh roy@10.0.0.18 (x86_64 Ubuntu, cross-compile aarch64) |
| Board | ssh root@10.0.2.0 |
Use the distribution cross-compiler; no need to build the full SDK host:
# build server (root)
apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu cmake
Sync source
The Android / armhf packages under 3rdparty/opencv are very large; this Demo only needs opencv-linux-aarch64 (statically linked in post-processing).
ssh roy@10.0.0.18 'mkdir -p ~/talowe-rv1126b-aidemo/talowe_ppocr_cam'
rsync -av --progress \
--exclude '.git' \
--exclude 'cpp/3rdparty/opencv/opencv-linux-armhf' \
--exclude 'cpp/3rdparty/opencv/opencv-android-sdk-build' \
--exclude 'cpp/build' \
--exclude 'cpp/install' \
~/SDK/talowe-rv1126b-aidemo/talowe_ppocr_cam/ \
roy@10.0.0.18:~/talowe-rv1126b-aidemo/talowe_ppocr_cam/
Confirm model/ppocrv4_det.rknn (about 2.5 MB) and model/ppocrv4_rec.rknn (about 6.9 MB) are already in the project model/.
Cross-compile
ssh roy@10.0.0.18
cd ~/talowe-rv1126b-aidemo/talowe_ppocr_cam/cpp
chmod +x build-linux.sh
./build-linux.sh
Output:
~/talowe-rv1126b-aidemo/talowe_ppocr_cam/cpp/install/rv1126b_linux_aarch64/rknn_ppocr_cam/
# lib model play.sdp ppocr.sdp rknn_ppocr_cam run_ppocr.sh
CMakeLists.txt / build-linux.sh use aarch64-linux-gnu-gcc, and link against the board's existing librockchip_mpp (a copy of the so is included in the package) as well as the bundled OpenCV static library.
Push to the board
The board's Buildroot usually has no rsync; create a tar on the build machine and extract it:
ssh roy@10.0.0.18 \
'tar czf - -C ~/talowe-rv1126b-aidemo/talowe_ppocr_cam/cpp/install/rv1126b_linux_aarch64 rknn_ppocr_cam' \
| ssh root@10.0.2.0 'tar xzf - -C /root'
You can also use this when USB is connected via adb:
adb push rknn_ppocr_cam /root/
Then go back to steps 1 and 2 in Demonstration above.
Data path
IMX / Sensor
→ rkisp_mainpath /dev/video12 (NV12 1920x1080)
→ copy one NV12 frame for encoding (boxes / text)
→ RGA convert to RGB888
→ RKNN PP-OCRv4 det (text boxes)
→ perspective crop + RKNN PP-OCRv4 rec (characters)
→ draw quadrilaterals / scores / FPS on NV12
→ MPP H.264 (each IDR carries SPS/PPS)
→ RTP PT=96 UDP → computer:5000
→ VLC opens ppocr.sdp
The resolution and port are written in cpp/main.cc, cpp/run_ppocr.sh, ppocr.sdp / play.sdp; when changing 1080p / 5000, change all three places.
FAQ
| Symptom | Handling |
|---|---|
| VLC stays black | Close VLC first, reopen ppocr.sdp, then start the board side; the fourth parameter must be the computer IP; allow UDP 5000 locally |
Camera open failed / VIDIOC_S_FMT failed | Other Demos / rkipc are still running. ./run_ppocr.sh stops them |
| All black after opening the camera | ISP 3A is not up. The script starts rkaiq_3A_server /etc/iqfiles; confirm the module is inserted |
| Picture present but no boxes | The text must fully and clearly enter the frame; you can slightly lower threshold / box_threshold |
| Chinese on serial but no text on the picture | The bitmap font does not support Chinese; this is normal; check the [OCR] log |
| Web page / RTSP gone after demonstration | rkipc not restored: killall rknn_ppocr_cam then /etc/init.d/S99rkipc start |
Build missing aarch64-linux-gnu-gcc | On the build server apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu |
The RKNN model can not be found | ppocrv4_det.rknn / ppocrv4_rec.rknn were not placed in the project model/ before compiling |
| OpenCV linking fails | Confirm cpp/3rdparty/opencv/opencv-linux-aarch64 has been synced (do not exclude the whole opencv directory) |
Camera node confirmation:
v4l2-ctl --list-devices
rkisp_mainpath (platform:rkisp-vir0):
/dev/video12
Differences from pose / YOLO
| Human Pose | YOLOv5 | YOLO11 | This page PP-OCR | |
|---|---|---|---|---|
| Project | talowe_yolov8_pose_cam | talowe_yolov5_detection_cam | talowe_yolo11_detection_cam | talowe_ppocr_cam |
| Model | yolov8_pose.rknn | yolov5.rknn ~7.4 MB | yolo11.rknn ~4.2 MB | ppocrv4_det.rknn + ppocrv4_rec.rknn |
| Output | Boxes + 17-keypoint skeleton | Boxes + 80 COCO class names | Boxes + 80 COCO class names | Quadrilateral text boxes + recognized strings |
| Stream receive | VLC play.sdp | VLC yolov5.sdp | VLC yolo11.sdp | VLC ppocr.sdp |
| With rkipc | Must stop | Must stop | Must stop | Must stop |
This Demo has 4 startup parameters (det, rec, camera, computer IP), one more recognition model than YOLO.
Download source code and prebuilt packages
Link: https://pan.baidu.com/s/15rNLzfb12Af8Sh_DX-KVBw?pwd=fanc
Extraction code: fanc
The cloud drive contains two archives:
| Package | Purpose |
|---|---|
talowe-rv1126b-aidemo | Source code, cross-compile yourself |
talowe-rv1126b-aidemo-app | Already compiled board-side programs (aarch64); copy to /root/ on the board and they run |
Notes for sending to customers / using yourself:
run_*.shpushes H.264 to10.0.0.49:5000by default. This is an example computer IP and must be changed to the stream-receiving computer's own LAN IP:./run_xxx.sh <computer IP>.- Firmware must be CAM126B-P Buildroot IPC. The Demo and
rkipcshare/dev/video12and cannot run simultaneously; the script stopsrkipcfirst. - Open VLC on the computer with the sdp corresponding to this page (this page is
ppocr.sdp, port 5000); do not mix it with other Demos' sdp. - In
talowe-rv1126b-aidemo-app, please ignorerknn_yolov5_demo(leftover from the old image inference). For live camera detection userknn_yolov5_detection_cam. - Most Demos in the source have been changed to V4L2 + RGA + MPP; no need to include the entire
3rdparty/opencv(about 11 × 525 MB). Only the PP-OCR cross-compilation on this page still needs the in-project OpenCV static library.
Summary
- Open
ppocr.sdpin VLC on the computer (wait for UDP 5000) - On the board
cd /root/rknn_ppocr_cam && ./run_ppocr.sh 10.0.0.49 - After screenshot / demonstration
killall rknn_ppocr_cam,/etc/init.d/S99rkipc start