Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

As said before, try to use the newer C++ interface. With the new interface, grabbing the image from the camera is easier than anything you could think of. Here's some sample code:

#include <opencv2/highgui/highgui.hpp>
int main()
{
    CvCapture *cam1 = cvCaptureFromCAM(0);
    while(true)
    {
        if(cam1)
        {
            Mat img = cvQueryFrame(cam1);
            //put your code here. img contains the picture from the camera.
        }
    }
}

I have never encountered any problem like this. The only time I have a camera failure is when my code is so cluttered that one small thing spoils everything. Try switching to Mat and garbage collection, coding and much more will be simpler!

Good luck! :)

As said before, try to use the newer C++ interface. With the new interface, grabbing the image from the camera is easier than anything you could think of. Here's some sample code:

#include <opencv2/highgui/highgui.hpp>
int main()
{
    CvCapture *cam1 = cvCaptureFromCAM(0);
cv::cvCaptureFromCAM(0);
    while(true)
    {
        if(cam1)
        {
            Mat cv::Mat img = cvQueryFrame(cam1);
cv::cvQueryFrame(cam1);
            //put your code here. img contains the picture from the camera.
        }
    }
}

I have never encountered any problem like this. The only time I have a camera failure is when my code is so cluttered that one small thing spoils everything. Try switching to Mat and garbage collection, coding and much more will be simpler!

Good luck! :)