Webcam doesn't work with openCV 1.0 C (CodeBlocks)

161 views Asked by At

I got a problem, I want a window with what my webcam displays; but what I have is a windows with ... a black I tried to got image dimensions, but it's a 0x0 My webcam is good, It works with displaying of Windows!! this's ma code (Windows 7 x64 bits)

#include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace std;

int main()
{
    IplImage* img;
    CvCapture* capture = cvCaptureFromCAM (CV_CAP_ANY);
    if (!capture)
        return 10;

    cvNamedWindow("video", CV_WINDOW_AUTOSIZE);
    char key = 'a';

    if (!cvGrabFrame(capture))
        return 20;

    while (key != 'q'){
        img = cvRetrieveFrame(capture);
        cvShowImage("video", img);

        key = cvWaitKey(60);

        if (!cvGrabFrame(capture))
            key = 'q';

    }
    cvDestroyAllWindows();
    img = NULL;
    cvReleaseCapture(&capture);

    return 0;
}
0

There are 0 answers