Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

first, you should avoid using opencv's no more maintained c-api (they moved away from that in 2010 already)

then, using -1 for camera id will throw you back into using vfw, which is quite problematic on win10.

#include "opencv2/opencv.hpp"
using namespace cv;

#include <iostream>
using namespace std;

int main()
{
    VideoCapture cap(0); // 1st device, DSHOW
    while(cap.isOpened())
    {
        Mat frame;
        cap >> frame;
        imshow("ocv",frame);

        int k = waitKey(10);
        if (k==27) break;
    }
    return 0;
}