Ask Your Question

Revision history [back]

Try for a starter to use this code sample, assuming you are using a recent version of OpenCV and report back if it works or not!

#include <opencv2/opencv.hpp>

using namespace cv;

int main( int argc, const char** argv )
{
    Mat image;

    VideoCapture cap(0);
    if(!cap.isOpened()){
        cerr << "No camera detected on this system" << endl;
        return -1;
    }

    while(true){
        cap >> image;
        if(image.empty()){
            cerr << "Frame invalid and skipped!" << endl;
            continue;
        }
        imshow("test", image);
        waitKey(5);
   }

   return 0;
}

Try for a starter to use this code sample, assuming you are using a recent version of OpenCV and report back if it works or not!

#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main( int argc, const char** argv )
{
    Mat image;

    VideoCapture cap(0);
    if(!cap.isOpened()){
        cerr << "No camera detected on this system" << endl;
        return -1;
    }

    while(true){
        cap >> image;
        if(image.empty()){
            cerr << "Frame invalid and skipped!" << endl;
            continue;
        }
        imshow("test", image);
        waitKey(5);
   }

   return 0;
}