Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
VideoCapture webcam;
webcam.open(device);
webcam.set(CV_CAP_PROP_FOURCC ,CV_FOURCC('M', 'J', 'P', 'G') );
webcam.set(CV_CAP_PROP_FRAME_WIDTH ,1920);

webcam.set(CV_CAP_PROP_FRAME_HEIGHT ,1080);

It's useful to set the Fourcc also in the original stream from the webcam, because if you don't set it to MJPG, it assumes RGB and so at HD res the fps is 5fps. In MJPG instead it goes at 25-30fps!

This code on Windows works:

VideoCapture webcam;
webcam.open(device);
webcam.open(0);
webcam.set(CV_CAP_PROP_FOURCC ,CV_FOURCC('M', 'J', 'P', 'G') );
webcam.set(CV_CAP_PROP_FRAME_WIDTH ,1920);
webcam.set(CV_CAP_PROP_FRAME_HEIGHT ,1080);

webcam.set(CV_CAP_PROP_FRAME_HEIGHT ,1080);The important thing is to set the Fourcc before the width.