uname -a
Linux Ubuntu 5.10.110 #5 SMP Thu Mar 2 17:39:26 CST 2023 aarch64 aarch64 aarch64 GNU/Linux
系统是论坛上下载的Ubuntu
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
USB摄像头:
(rknn_py39) edwardzhou@Ubuntu:~/opencv_work/build$ v4l2-ctl -d /dev/video20 --all
Driver Info:
Driver name : uvcvideo
Card type : USB PHY 2.0: USB CAMERA
Bus info : usb-fc800000.usb-1.3
Driver version : 5.10.110
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : uvcvideo
Model : USB PHY 2.0: USB CAMERA
Serial :
Bus info : usb-fc800000.usb-1.3
Media version : 5.10.110
Hardware revision: 0x00000100 (256)
Driver version : 5.10.110
Interface Info:
ID : 0x03000002
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : USB PHY 2.0: USB CAMERA
Function : V4L2 I/O
Flags : default
Pad 0x01000007 : 0: Sink
Link 0x02000013: from remote pad 0x100000a of entity 'Extension 4' (Video Pixel Formatter): Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'MJPG' (Motion-JPEG)
Field : None
Bytes per Line : 0
Size Image : 4177920
Colorspace : sRGB
Transfer Function : Rec. 709
YCbCr/HSV Encoding: ITU-R 601
Quantization : Default (maps to Full Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 640, Height 480
Default : Left 0, Top 0, Width 640, Height 480
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags:
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30/1)
Read buffers : 0
white_balance_temperature 0x0098091a (int) : min=0 max=255 step=1 default=128 value=128
发现有两个问题:
-
usb摄像头如果接 USB3.0的那两个蓝色接口,无法工作,gst打不开。接 USB2.0的插口,才能工作。
-
用gst-launch-1.0 测试
1) 有时会直接失败, 再次又能成功
失败日志:
(rknn_py39) edwardzhou@Ubuntu:~/opencv_work/build$ gst-launch-1.0 v4l2src device=/dev/video20 ! image/jpeg,width=640,height=480 ! jpegparse ! mppjpegdec ! videoconvert ! appsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
libv4l2: error turning on stream: Input/output error
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate required memory.
Additional debug info:
../sys/v4l2/gstv4l2src.c(800): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Buffer pool activation failed
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.067890509
Setting pipeline to NULL ...
Freeing pipeline ...
2) 能成功拉取,过十几秒又会自动中断
开始成功的输出
(rknn_py39) edwardzhou@Ubuntu:~/opencv_work/build$ gst-launch-1.0 v4l2src device=/dev/video20 ! image/jpeg,width=640,height=480 ! jpegparse ! mppjpegdec ! videoconvert ! appsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
0:00:07.9 / 99:99:99.
拉取过十几秒后失败 自动断开
rknn_py39) edwardzhou@Ubuntu:~/opencv_work/build$ gst-launch-1.0 v4l2src device=/dev/video20 ! image/jpeg,width=640,height=480 ! jpegparse ! mppjpegdec ! videoconvert ! appsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason error (-5)
Execution ended after 0:00:13.670819439
Setting pipeline to NULL ...
Freeing pipeline ...