Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

H.264, and MJPEG are video codecs and can't apply to a single frame. In OpenCV you can save grabbed frames as video file with VideoWriter using all available codes on you computer.

YUV4:2:2 is an image format and it could be ok as grab format, but, I'm not sure, OpenCV grabs only in BGR format. You could play with grab properties mode and or frame format.

Look at the doc here and set desired properties after connection for frame size:

VideoCapture cap(0); // open the default camera
if(!cap.isOpened())  // check if we succeeded
  return -1;
// set frame size to 320x240 pix
cap.set(CV_CAP_PROP_FRAME_WIDTH,320);
cap.set(CV_CAP_PROP_FRAME_HEIGHT,240);

For image format: Unfortunately properties aren't well documented, some of them are device dependant, you could to play around them to check if it's works

double grabMode,frameFormat,settings;
bool ok = false;
// Backed-specific value indicating the current capture mode.
grabMode = cap.get(CV_CAP_PROP_MODE);
// Format of the Mat objects returned by retrieve()
frameFormat = cap.get(CV_CAP_PROP_FORMAT); 
// Some available settings 
settings = cap.get(CV_CAP_PROP_SETTINGS);

// Playing around GRAB_MODE

// Boolean flags indicating whether images should be converted to RGB.
cap.set(CV_CAP_PROP_CONVERT_RGB, 0);
int i = -100;
while(ok == false && i<10)
{
 if (i != 0)
   ok = cap.set(CV_CAP_PROP_MODE, grabMode + i);
 i++;
}
if(ok)
{
 grabMode = cap.get(CV_CAP_PROP_MODE);
 cout << "Grab Mode=" << grabMode << " is supported" << endl;
}