【BIGTREETECH PI开发板】+04.UVC(USB摄像头)测试(zmj)
BIGTREETECH PI开发板没有预留MIPI-CSI接口,但是它支持常见的USB摄像头(UVC),因此本节主要测试内容围绕USB-Camera展开。
//------UVC / USB-Camera
UVC通俗的讲就是USB摄像头,全称为USB Video Class,即:USB视频类,是一种为USB视频捕获设备定义的协议标准。
1. 摄像头接口设备
摄像头设备位于” /dev/video*“。一般情况下, /dev/video0为USB摄像头。
//------查看摄像头设备节点
a.通过设备列表查看
ls -la /dev/video*
b.通过v4l2-ctl工具查看
v4l2-ctl --list-devices
c.通过media0检查有效摄像头节点
media-ctl -d /dev/media0 -p
//------示例Log信息
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ v4l2-ctl --list-devices
USB 2.0 Camera: USB Camera (usb-5101000.usb-1.1):
/dev/video0
/dev/video1
/dev/media0
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ ^C
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ ^C
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ ^C
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ ls -la /dev/video*
crw-rw---- 1 root video 81, 0 Aug 6 10:02 /dev/video0
crw-rw---- 1 root video 81, 1 Aug 6 10:02 /dev/video1
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ v4l2-ctl --list-devices
USB 2.0 Camera: USB Camera (usb-5101000.usb-1.1):
/dev/video0
/dev/video1
/dev/media0
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ media-ctl -d /dev/media0 -p
Media controller API version 5.16.17
Media device information
------------------------
driver uvcvideo
model USB 2.0 Camera: USB Camera
serial
bus info usb-5101000.usb-1.1
hw revision 0x0
driver version 5.16.17
Device topology
- entity 1: USB 2.0 Camera: USB Camera (1 pad, 1 link)
type Node subtype V4L flags 1
device node name /dev/video0
pad0: Sink
<- "Extension 3":1 [ENABLED,IMMUTABLE]
- entity 4: USB 2.0 Camera: USB Camera (0 pad, 0 link)
type Node subtype V4L flags 0
device node name /dev/video1
- entity 8: Extension 3 (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
pad0: Sink
<- "Processing 2":1 [ENABLED,IMMUTABLE]
pad1: Source
-> "USB 2.0 Camera: USB Camera":0 [ENABLED,IMMUTABLE]
- entity 11: Processing 2 (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
pad0: Sink
<- "Camera 1":0 [ENABLED,IMMUTABLE]
pad1: Source
-> "Extension 3":0 [ENABLED,IMMUTABLE]
- entity 14: Camera 1 (1 pad, 1 link)
type V4L2 subdev subtype Sensor flags 0
pad0: Source
-> "Processing 2":0 [ENABLED,IMMUTABLE]
biqu@BTT-CB1:~/zmj_ws/gui_gpu$
//------检查USB-Camera
2. USB摄像头测试
将USB摄像头插入开发板,将自动安装 uvc 添加设备节点。 注意:测试分辨率越高,视频效果越卡……
//------USB-Camera(某宝几十块买的USB摄像头)
a.确认USB摄像头的设备节点,此处为/dev/video0。
v4l2-ctl --list-devices
b.查看摄像头支持的格式与分辨率
v4l2-ctl --list-formats-ext -d /dev/video0
c.摄像头预览(视频)
gst-launch-1.0 v4l2src device=/dev/video0 ! "video/x-raw, width=640, Height=480, framerate=(fraction)30/1" ! queue ! glimagesink
或者
ffplay -f video4linux2 -framerate 30 -video_size hd720 /dev/video0
d.摄像头预览(拍照)
gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=3 ! jpegenc ! filesink location=~/pic_of_video0.jpg
e.USB-Camera设备信息(查看硬件变动信息即可)
dmesg | tail -11
//------测试Log信息(拍照)
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=3 ! jpegenc ! filesink location=~/pic_of_video0.jpg
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:02.205011637
Setting pipeline to NULL ...
Freeing pipeline ...
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ ll ~
total 1172
drwxr-xr-x 10 biqu biqu 4096 Mar 3 11:39 crowsnest
drwxr-xr-x 11 biqu biqu 4096 Mar 3 11:27 klipper
drwxr-xr-x 9 biqu biqu 4096 Mar 3 11:40 KlipperScreen
drwxr-xr-x 5 biqu biqu 4096 Mar 3 09:25 klippy-env
drwxr-xr-x 5 biqu biqu 4096 Mar 3 11:39 mainsail
drwxr-xr-x 3 biqu biqu 4096 Mar 3 11:39 mainsail-config
drwxr-xr-x 8 biqu biqu 4096 Mar 3 09:26 moonraker
drwxr-xr-x 4 biqu biqu 4096 Mar 3 09:27 moonraker-env
drwxr-xr-x 8 biqu biqu 4096 Mar 3 11:40 moonraker-timelapse
-rw-r--r-- 1 biqu biqu 1146415 Aug 6 10:13 pic_of_video0.jpg
drwxr-xr-x 3 biqu biqu 4096 Mar 3 11:40 print_area_bed_mesh
drwxr-xr-x 10 biqu biqu 4096 Mar 3 09:29 printer_data
drwxr-xr-x 8 biqu biqu 4096 Mar 3 11:40 sonar
drwxr-xr-x 17 biqu biqu 4096 Jul 23 12:47 zmj_ws
biqu@BTT-CB1:~/zmj_ws/gui_gpu$ eog ~/pic_of_video0.jpg
//------拍照功能测试:
//------视频功能测试:
uvc_video
//------end