读普通读取视频文件的OpenCV代码
cv::VideoCapture cap;
cap.open("xxx.mp4");
Mat frame;
while(cap.read(frame))
{
//处理图像 frame
}
cap.release();
查看设备信息
列出所有设备v4l2-ctl--list-devices查看某一个设备的具体信息,数据接口格式v4l2-ctl-d/dev/video0-all
Driver Info:
Driver name : rkcif
Card type : rkcif
Bus info : platform:rkcif-mipi-lvds2
Driver version : 5.10.110
Capabilities : 0x84201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Media Driver Info:
Driver name : rkcif
Model : rkcif-mipi-lvds2
Serial :
Bus info :
Media version : 5.10.110
Hardware revision: 0x00000000 (0)
Driver version : 5.10.110
Interface Info:
ID : 0x03000002
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : stream_cif_mipi_id0
Function : V4L2 I/O
Pad 0x01000004 : 0: Sink
...
Priority: 2
Format Video Capture Multiplanar:
Width/Height : 1920/1080 # 后续读取摄像头的时候用的上
Pixel Format : "NV12" (Y/CbCr 4:2:0) # 后续读取摄像头的时候用的上
Field : None
Number of planes : 1
Flags :
Colorspace : Rec. 709
Transfer Function : Rec. 709
YCbCr/HSV Encoding: Rec. 709
Quantization : Default
Plane 0 :
Bytes per Line : 1920
Size Image : 3110400
Selection Video Capture: crop, Left 0, Top 0, Width 1920, Height 1080, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags:
Selection Video Output: crop, Left 0, Top 0, Width 1920, Height 1080, Flags:
Selection Video Output: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags:
OpenCV必须是支持有Gstreamer支持的,没有的话需要重新编译,添加WITH_GSTREAMER参数进行编译可以在程序中通过cout< 在系统终端中调用摄像头看像可以直接使用下面的命令:gst-launch-0v4l2srcdevice=/dev/video0io-mode=4!queue!video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1!glimagesink也可以预先测试gstreamer和摄像头是否正常运行,不过在代码中需要使用cpp代码中给出的形式 文章为作者独立观点,不代表股票交易接口观点