Skip to main content

Application Test - General Object Detection (YOLOv5)

Navigation bar

Run Talowe talowe_yolov5_detection_cam on CAM126B-P: the camera detects 80 COCO classes in real time, draws boxes, and pushes H.264 RTP to the computer. Open yolov5.sdp in VLC to view the picture.

Source: https://github.com/hbt021211-coder/talowe-rv1126b-aidemo

Inference: RKNN | Capture: V4L2 /dev/video12 NV12 1920x1080 | Encoding: MPP | Stream receive: UDP 5000

Information

Talowe's original project uses OpenCV + GStreamer. The factory Buildroot IPC does not have these two libraries.
The current Demo has been changed to V4L2 + RGA + MPP; flash the IPC firmware and you can demonstrate, no need to rebuild rootfs.

Firmware

The procedure on this page is written for CAM126B-P Buildroot IPC (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.

Warning

This Demo shares camera /dev/video12 and UDP 5000 with Human Pose Detection and YOLO26 Detection, and cannot run simultaneously.
Before starting this page, stop the other Demos: killall rknn_yolov8_pose_demo rknn_yolo26_detection_cam. run_detect.sh will also kill the pose process.


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.

RoleAddressDescription
Stream-receiving computer (Mac)10.0.0.49Install VLC, open yolov5.sdp
CAM126B-Pssh root@10.0.2.0Default password see Firmware Usage
Program directory/root/rknn_yolov5_detection_camAlready deployed package

1. Open VLC on the computer first​

Copy yolov5.sdp to the computer, e.g. ~/yolov5.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=Detection
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=Detection); it has the same filename as the pose play.sdp (s=Pose) but a different session name. For this page use yolov5.sdp to avoid mixing it with the pose stream file.

open -a VLC ~/yolov5.sdp

Or VLC → File → Open File → select yolov5.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_yolov5_detection_cam
./run_detect.sh 10.0.0.49

run_detect.sh will: stop the pose Demo / rkipc (otherwise it occupies the camera) → open /dev/video12 → infer and draw boxes → 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 ...
[DET] person | box:( 412 , 201)( 890 , 980) | size: 478*779 | conf: 87.32%

VLC should show a live picture: detection boxes, class name, confidence, and FPS in the upper-left corner. COCO objects such as people, cups, keyboards, and phones will be boxed when they enter the frame.

Manual equivalent command (when not using the script):

/etc/init.d/S99rkipc stop
cd /root/rknn_yolov5_detection_cam
export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
./rknn_yolov5_detection_cam ./model/yolov5.rknn /dev/video12 10.0.0.49

The third parameter must be the computer IP, not 10.0.2.0.

3. After the demonstration, restore IPC​

After stopping the Demo with Ctrl + C:

killall rknn_yolov5_detection_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_yolov5_detection_cam# ls
lib model play.sdp rknn_yolov5_detection_cam run_detect.sh yolov5.sdp
FilePurpose
rknn_yolov5_detection_camMain program
run_detect.shStop rkipc and start; parameter is the computer IP
yolov5.sdpCopy to the computer for VLC (recommended)
play.sdpSame content as yolov5.sdp, s=Detection
model/yolov5.rknnDetection model (about 7.4 MB, 80 COCO classes)
model/coco_80_labels_list.txtClass names; post-processing reads ./model/coco_80_labels_list.txt
lib/librknnrt.so librga.so librockchip_mpp.soNPU / RGA / encoding

Startup parameters:

./rknn_yolov5_detection_cam <model_path> <camera_index> <target_ipv4>
  • <camera_index>: ISP main path; on this board it is /dev/video12 (rkisp_mainpath in v4l2-ctl --list-devices)
  • <target_ipv4>: LAN IP of the stream-receiving computer; port is hardcoded 5000

The 80 COCO classes include person, bicycle, car, bottle, cup, chair, laptop, cell phone, etc. Thresholds are in postprocess.h: BOX_THRESH default 0.25, NMS_THRESH default 0.45.


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​

RoleExample
Local machine~/SDK/talowe-rv1126b-aidemo (Mac only edits code and rsyncs)
Build serverssh roy@10.0.0.18 (x86_64 Ubuntu, cross-compile aarch64)
Boardssh 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​

3rdparty/opencv is about 525 MB and is not used by this Demo; do not sync it.

ssh roy@10.0.0.18 'mkdir -p ~/talowe-rv1126b-aidemo/talowe_yolov5_detection_cam'

rsync -av --progress \
--exclude '.git' \
--exclude 'cpp/3rdparty/opencv' \
--exclude 'cpp/build' \
--exclude 'cpp/install' \
~/SDK/talowe-rv1126b-aidemo/talowe_yolov5_detection_cam/ \
roy@10.0.0.18:~/talowe-rv1126b-aidemo/talowe_yolov5_detection_cam/

Confirm model/yolov5.rknn is about 7.4 MB and already in the project model/.

Cross-compile​

ssh roy@10.0.0.18
cd ~/talowe-rv1126b-aidemo/talowe_yolov5_detection_cam/cpp
chmod +x build-linux.sh
./build-linux.sh

Output:

~/talowe-rv1126b-aidemo/talowe_yolov5_detection_cam/cpp/install/rv1126b_linux_aarch64/rknn_yolov5_detection_cam/
# lib model play.sdp rknn_yolov5_detection_cam run_detect.sh yolov5.sdp

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).

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_yolov5_detection_cam/cpp/install/rv1126b_linux_aarch64 rknn_yolov5_detection_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_yolov5_detection_cam /root/

Then go back to steps 1 and 2 in Demonstration above.


Data path​

IMX / Sensor
→ rkisp_mainpath /dev/video12 (NV12 1920x1080)
→ RGA convert to RGB888
→ RKNN YOLOv5 (80 COCO classes)
→ draw boxes / class names / confidence / FPS
→ RGA convert back to NV12
→ MPP H.264
→ RTP PT=96 UDP → computer:5000
→ VLC opens yolov5.sdp

The resolution and port are written in cpp/main.cc, cpp/run_detect.sh, yolov5.sdp / play.sdp; when changing 1080p / 5000, change all three places.


FAQ​

SymptomHandling
VLC stays black / audio present but all blackThe board log already has [DET] person, which means the camera is producing images. In older versions the RGB→NV12 encoding buffer may be empty; close VLC first, rerun ./run_detect.sh, and open with yolov5.sdp. The third parameter must be the computer IP; allow UDP 5000 locally
Camera open failed / VIDIOC_S_FMT failedrkipc or the pose Demo is still running. ./run_detect.sh stops them, or manually killall rknn_yolov8_pose_demo and then /etc/init.d/S99rkipc stop
All black after opening the cameraISP 3A is not up. The script starts rkaiq_3A_server /etc/iqfiles; confirm the module is inserted
Picture present but no boxesThe object must fully enter the frame; thresholds are in postprocess.h BOX_THRESH (default 0.25)
Class names are all null / garbledYou must start from the package root directory; post-processing reads ./model/coco_80_labels_list.txt
Web page / RTSP gone after demonstrationrkipc not restored: killall rknn_yolov5_detection_cam then /etc/init.d/S99rkipc start
Build missing aarch64-linux-gnu-gccOn the build server apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
The RKNN model can not be foundyolov5.rknn was not placed in the project model/ before compiling

Camera node confirmation:

v4l2-ctl --list-devices
rkisp_mainpath (platform:rkisp-vir0):
/dev/video12

Differences from the pose Demo and the official image Demo​

Human PoseThis page YOLOv5 CamYOLO26
Modelyolov8_pose.rknnyolov5.rknnyolo26.rknn
OutputBoxes + 17-keypoint skeletonBoxes + 80 COCO class namesBoxes + 80 COCO class names
Stream receiveVLC play.sdpVLC yolov5.sdpVLC yolo26.sdp
With rkipcMust stopMust stopMust stop

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:

PackagePurpose
talowe-rv1126b-aidemoSource code, cross-compile yourself
talowe-rv1126b-aidemo-appAlready compiled board-side programs (aarch64); copy to /root/ on the board and they run

Notes for sending to customers / using yourself:

  1. run_*.sh pushes H.264 to 10.0.0.49:5000 by 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>.
  2. Firmware must be CAM126B-P Buildroot IPC. The Demo and rkipc share /dev/video12 and cannot run simultaneously; the script stops rkipc first.
  3. Open VLC on the computer with the sdp corresponding to this page (this page is yolov5.sdp, port 5000); do not mix it with other Demos' sdp.
  4. In talowe-rv1126b-aidemo-app, please ignore rknn_yolov5_demo (leftover from the old image inference). For live camera detection use rknn_yolov5_detection_cam.
  5. 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 PP-OCR cross-compilation still needs the in-project OpenCV static library.

Summary​

  1. Open yolov5.sdp in VLC on the computer (wait for UDP 5000)
  2. On the board cd /root/rknn_yolov5_detection_cam && ./run_detect.sh 10.0.0.49
  3. After screenshot / demonstration killall rknn_yolov5_detection_cam, /etc/init.d/S99rkipc start
AI Translation Notice

This page was translated into English by AI and is provided for reference only. The original document is written in Chinese. If there is any discrepancy, the Chinese version prevails.

本页英文内容由 AI 自动翻译生成,仅供参考;原文为中文,如有差异请以中文原文为准。

查看中文原文 / View the Chinese original →