Ask Your Question

Revision history [back]

You can use :

cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, 640 );
cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 480 );

or resize the image (not recommended):

resize(img,img,Size(640,480);

You can use :

cvSetCaptureProperty( capture, webcam, CV_CAP_PROP_FRAME_WIDTH, 640 );
cvSetCaptureProperty( capture, webcam, CV_CAP_PROP_FRAME_HEIGHT, 480 );

or resize the image (not recommended):

resize(img,img,Size(640,480);

You can use :

cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_WIDTH, 640 );
cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_HEIGHT, 480 );

or resize the image (not recommended):

resize(img,img,Size(640,480);
resize(img,img,Size(640,480));

You can use :

cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_WIDTH, 640 );
cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_HEIGHT, 480 );

or resize the image (not recommended):

resize(img,img,Size(640,480));

p.p. In your case:

int main() {
    CvCapture *webcam = cvCreateCameraCapture(0); 
    cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_WIDTH, 640 );
    cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_HEIGHT, 480 );

    if (!webcam)return -1;
    while (true) {
        Mat img = cvQueryFrame(webcam);
        if (img.data) {
            imwrite("photo.jpg",img);
            imshow("Photo",img);
            if (waitKey(3000) == 0x1B) break;
        }
    }
    return 0;
}

You can use :

cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_WIDTH, 640 );
cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_HEIGHT, 480 );

or resize the image (not recommended):

resize(img,img,Size(640,480));

p.p. In your case:

int main() {
    CvCapture *webcam = cvCreateCameraCapture(0); 
    cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_WIDTH, 640 );
    cvSetCaptureProperty( webcam, CV_CAP_PROP_FRAME_HEIGHT, 480 );

    if (!webcam)return -1;
    while (true) {
        Mat img = cvQueryFrame(webcam);
        if (img.data) {
            imwrite("photo.jpg",img);
            imshow("Photo",img);
            if (waitKey(3000) == 0x1B) break;
        }
    }
    return 0;
}