Ask Your Question

Revision history [back]

You can use set method:

VideoCapture cap(0);

if (!cap.isOpened()) {
    cerr << "ERROR! Unable to open camera\n";
    return -1;
}
cap.set(CAP_PROP_FRAME_WIDTH ,1280);
cap.set(CAP_PROP_FRAME_HEIGHT,720);
if (cap.get(CAP_PROP_FRAME_HEIGHT)!=720 || cap.get(CAP_PROP_FRAME_WIDTH)!=1280)
     cout<<"unable to set 1280*720\n";

You can use set method:

VideoCapture cap(0);

VideoCapture cap(0);

if (!cap.isOpened()) {
    cerr << "ERROR! Unable to open camera\n";
    return -1;
}
cap.set(CAP_PROP_FRAME_WIDTH ,1280);
cap.set(CAP_PROP_FRAME_HEIGHT,720);
if (cap.get(CAP_PROP_FRAME_HEIGHT)!=720 || cap.get(CAP_PROP_FRAME_WIDTH)!=1280)
     cout<<"unable to set 1280*720\n";