Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Webcam image size

Hello, I've downloaded OpenCV and made a simple program which takes a photo of you using the webcam. But the size of photos is only 160x120 so I was wondering if I can somehow scale it. I tried to use cvResize but it didn't help. Can anybody help me? Here is the code:

int main() {
    CvCapture *webcam = cvCreateCameraCapture(0); 
    if (!webcam)
        return 1;
    while (1) {
        IplImage *camImg = cvQueryFrame(webcam),*camImgSize = cvCreateImage(cvSize(640,480),camImg->depth,camImg->nChannels);
        if (camImg) {
            cvResize(camImg,camImgSize,CV_INTER_LINEAR);
            cvSaveImage("photo.jpg",camImg,0);
            cvShowImage("Photo",camImg);
            if (cvWaitKey(3000) == 0x1B) break;
        }
    }
    return 0;
}