Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

After loop you decrease num variable. And when you open cap before reading frame you decrease it again. Remove one of decrement.

unsigned int num = 0;
cv::VideoCapture cap;
while(true)
{
    cap.open(num++);
    if(!cap.isOpened())
        break;
    cap.release();
}

Mat frame;
cap.open(num-1);
cap >> frame;
cv::imwrite("test.jpg", frame);