Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

c++ - Can't use div2usb with OpenCV on Linux

I try to use the dvi2usb grabber 2 with OpenCv in C++ and Ubuntu. For some reason I can’t get it:

cv::VideoCapture cap;

if(!cap.open("/dev/video4", cv::CAP_V4L2)){
    cout << "NOT POSSIBLE" << endl;
    return -1;
}

So it will always enter this if condition. this works just fine for my other cheap usb grabber and my webcam but not for the Epiphan. The grabber uses V4L2. I can get the Epiphan on OBS which uses V4L2 as well, but not with OpenCv.

if I set a few parameters before cap.open:

cap.set(cv::CAP_PROP_FRAME_WIDTH, 1920);
cap.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);
cap.set(cv::CAP_PROP_FPS, 50);

I get a warning:

…cap_v4l.cpp (836) createBuffers VIDEOIO(V4L2:/dev/video4): failed mmap(6220800): errno=22 (Invalid argument)

When I look up the available formats in terminal with:

v4l2-ctl -d /dev/video0 --list-formats

I get this result:

v4l2-ctl -d /dev/video4 --list-formats
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: ‘RGB3’
Name : 24-bit RGB 8-8-8

Index : 1
Type : Video Capture
Pixel Format: ‘BGR3’
Name : 24-bit BGR 8-8-8

Index : 2
Type : Video Capture
Pixel Format: ‘RGB4’
Name : 32-bit A/XRGB 8-8-8-8

Index : 3
Type : Video Capture
Pixel Format: ‘RGBP’
Name : 16-bit RGB 5-6-5

Index : 4
Type : Video Capture
Pixel Format: ‘UYVY’
Name : UYVY 4:2:2

Index : 5
Type : Video Capture
Pixel Format: ‘YUYV’
Name : YUYV 4:2:2

Index : 6
Type : Video Capture
Pixel Format: ‘YU12’
Name : Planar YUV 4:2:0

Index : 7
Type : Video Capture
Pixel Format: ‘YV12’
Name : Planar YVU 4:2:0

Index : 8
Type : Video Capture
Pixel Format: ‘NV12’
Name : Y/CbCr 4:2:0

I guess I have to configure the VideoCapture a little more with the CAP_PROP_.. options, but I don’t know which one, but maybe I am wrong and something else is not correct. I am grateful for all advises to fix this. BR Michael

question from:https://stackoverflow.com/questions/65902229/cant-use-div2usb-with-opencv-on-linux

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...