Ask Your Question

frank10's profile - activity

2013-02-11 06:51:43 -0600 received badge  Editor (source)
2013-02-11 06:48:39 -0600 answered a question How to Get MJPEG compression format from webcam!

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(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);

The important thing is to set the Fourcc before the width.