Capturing 1080p at 30fps from logitech c920 with openCV 2.4.3

自古美人都是妖i 提交于 2019-11-30 00:11:18
ns130291

As the author of the post already found the solution but didn't add it as an answer I will put the solution here.

You have to set the codec before you set the wanted resolution:

this->camRef.set(CV_CAP_PROP_FOURCC,CV_FOURCC('M','J','P','G'));
this->camRef.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
this->camRef.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);

working with logitech c922, needed:

capture.open(CV_CAP_DSHOW);
capture.set(CV_CAP_PROP_FOURCC, CV_FOURCC('M', 'J', 'P', 'G'));
capture.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);
cyriel

Try to get first frame from capture before setting anything:

VideoCapture cap(0);
if(!cap.isOpened()) 
return -1;  

Mat frame;
cap >> frame;
double fps;
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1080.0);
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1920.0);
//add the loop here

and check whether it will work without setting MJPG. If it will work, try with MJPG.

For me it's a bit weird that you have to get first frame before setting anything, but it's the only way it's working for me (windows 7 32bit).



//edit:
Yo may try to use different API - see second part of my answer here: https://stackoverflow.com/a/14188280/1598485 OpenCV is trying to use the best API by default, but maybe in your case some other API will work better.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!