本文适用与触觉智能所有RK356X ubuntu系统的主板。
IDO-SBC3566基于瑞芯微RK3566研发的一款高性能低功耗的智能主板,采用四核A55,主频高达1.8GHz,专为个人移动互联网设备和AIOT设备而设计,内置了多种功能强大的嵌入式硬件引擎,为高端应用提供了优异的性能,支持几乎全格式的4K编解码,内置3DGPU,能够完全兼容OpenGL ES1.1/2.0/3.2、OpenCL2.0和Vulkan1.0.特殊的MMU2D硬件引擎,此外,凭借其强大的兼容性,可以轻松地转换基于TensorFlow/MXNet/PyTorch/Caffe等一系列框架的网络模型。
支持Android,Linux,OpenHarmony,麒麟OS等多种操作系统,可广泛应用于平板、教育平板、带屏音箱、词典笔、云终端、视频会议系统等安卓/Linux类应用方案,以及其他带屏消费类、或轻量级AI应用场景。
产品规格书查看深圳触觉智能官网-产品中心
01 确认USB摄像头设备节点
主板接上USB摄像头后,使用以下命令查看USB摄像头的设备节点:
root@ido:~# v4l2-ctl --list-devices
rkisp-statistics (platform: rkisp):
/dev/video7
/dev/video8
rkisp_mainpath (platform:rkisp-vir0):
/dev/video0
/dev/video1
/dev/video2
/dev/video3
/dev/video4
/dev/video5
/dev/video6
/dev/media0
AC_2019053011080005: ZH-0305 (usb-xhci-hcd.4.auto-1):
/dev/video9
/dev/video10
/dev/media1
video9即为USB摄像头的设备节点。
02 查看USB摄像头支持的图像格式
root@ido:~# v4l2-ctl -d /dev/video9 --list-formats-ext --all
...
...
...
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'MJPG' (Motion-JPEG, compressed)
Size: Discrete 1024x576
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 896x504
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 800x600
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
[1]: 'YUYV' (YUYV 4:2:2)
Size: Discrete 1280x720
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 1024x576
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 896x504
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 800x600
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
可以看到,该USB摄像头支持MPEG格式最高1280x720@30FPS输出。
03推流到电脑上
RK356X主板将USB摄像头图像推流到电脑上显示。
3.1 主板安装gst-rtsp插件
apt install gstreamer1.0-rtsp
apt install gstreamer1.0-rtsp
3.2 主板安装mediamtx
mediamtx是一个rtsp server程序
root@ido:/home/ido# tar -xvf mediamtx_v1.1.1_linux_arm64v8.tar.gz
mediamtx
mediamtx.yml
LICENSE
root@ido:/home/ido# ./mediamtx &
[1] 1315
root@ido:/home/ido# 2023/10/20 02:56:04 INF MediaMTX v1.1.1
2023/10/20 02:56:04 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2023/10/20 02:56:04 INF [RTMP] listener opened on :1935
2023/10/20 02:56:04 INF [HLS] listener opened on :8888
2023/10/20 02:56:04 INF [WebRTC] listener opened on :8889 (HTTP)
2023/10/20 02:56:04 INF [SRT] listener opened on :8890 (UDP)
mediamtx安装包可到以下链接下载:
链接:https://pan.baidu.com/s/1CXrk7eJIkUJKD4tK1SkFAA?pwd=1234
提取码:1234
3.3 主板开始RTSP推流
查看主板的IP地址:
root@ido:/home/ido# ifconfig
eth0: flags=4163 mtu 1500
inet 192.168.1.196 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::d079:b6fc:c367:fea6 prefixlen 64 scopeid 0x20
ether 86:41:8a:06:1d:7c txqueuelen 1000 (Ethernet)
RX packets 52836 bytes 38891607 (38.8 MB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 885065 bytes 1255645741 (1.2 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 40
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 284667 bytes 313713612 (313.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 284667 bytes 313713612 (313.7 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
使用gst-launch-1.0工具进行RTSP推流:
gst-launch-1.0 v4l2src device=/dev/video9 \
! image/jpeg ! avdec_mjpeg ! videoconvert \
! video/x-raw,height=720,width=1280,frame=30/1,format=NV12 ! mpph264enc \
! rtspclientsink location=rtsp://127.0.0.1:8554/stream
3.4 电脑播放
电脑打开VLC软件,点击【媒体】->【打开网络串流】->【网络】,并输入主板的RTSP推流地址和端口,然后点击播放:
点击播放按钮后,即可看到USB摄像头的图像了:
04推流到RK356X主板
RK356X主板A将USB摄像头推流到RK356X主板B上播放。
4.1 主板A安装gst-rtsp插件
sudo apt install gstreamer1.0-rtsp
4.2 主板A安装mediamtx
sudo apt install gstreamer1.0-rtsp
4.2 主板A安装mediamtx
mediamtx是一个rtsp server程序
sudo apt install gstreamer1.0-rtsp
root@ido:/home/ido# tar -xvf mediamtx_v1.1.1_linux_arm64v8.tar.gz
mediamtx
mediamtx.yml
LICENSE
root@ido:/home/ido# ./mediamtx &
[1] 1315
root@ido:/home/ido# 2023/10/20 02:56:04 INF MediaMTX v1.1.1
2023/10/20 02:56:04 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2023/10/20 02:56:04 INF [RTMP] listener opened on :1935
2023/10/20 02:56:04 INF [HLS] listener opened on :8888
2023/10/20 02:56:04 INF [WebRTC] listener opened on :8889 (HTTP)
2023/10/20 02:56:04 INF [SRT] listener opened on :8890 (UDP)
mediamtx安装包可到以下链接下载:
链接:https://pan.baidu.com/s/1CXrk7eJIkUJKD4tK1SkFAA?pwd=1234
提取码:1234
4.3 主板A开始RTSP推流
查看主板A的IP地址:
root@ido:/home/ido# ifconfig
eth0: flags=4163 mtu 1500
inet 192.168.1.196 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::d079:b6fc:c367:fea6 prefixlen 64 scopeid 0x20
ether 86:41:8a:06:1d:7c txqueuelen 1000 (Ethernet)
RX packets 52836 bytes 38891607 (38.8 MB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 885065 bytes 1255645741 (1.2 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 40
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 284667 bytes 313713612 (313.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 284667 bytes 313713612 (313.7 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
使用gst-launch-1.0工具进行RTSP推流:
gst-launch-1.0 v4l2src device=/dev/video9 \
! image/jpeg ! avdec_mjpeg ! videoconvert \
! video/x-raw,height=720,width=1280,frame=30/1,format=NV12 ! mpph264enc \
! rtspclientsink location=rtsp://127.0.0.1:8554/stream
4.4 主板B拉流并播放
root@ido:~# gst-launch-1.0 playbin uri=rtsp://192.168.1.196:8554/stream
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.1.196:8554/stream
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
mpp[1359]: mpp_rt: NOT found ion allocator
mpp[1359]: mpp_rt: found drm allocator
mpp[1359]: mpp_info: mpp version: 49f29006 author: Jeffy Chen 2021-08-04 [drm]: Add mmap flag detection
mpp[1359]: hal_h264d_vdpu34x: control info: fmt 7, w 1280, h 720
mpp[1359]: mpp_buf_slot: set frame info: w 1280 h 720 hor 1280 ver 720
mpp[1359]: mpp_dec: setting default w 1280 h 720 h_str 1280 v_str 720
mpp[1359]: h264d_api: is_avcC=1