Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

that's an empty image. your camera probably needs a 'warmup' time, and delivers empty frames on startup.

try:

for(;;)
{
    Mat frame;

    cap >> frame;      // get a new frame from camera
    if (frame.empty()) // skip invalid images
         continue;

    imwrite("C:/Users/ankit/Desktop/12.png", frame);

}

that's an empty image. your camera probably needs a 'warmup' time, and delivers empty frames on startup.

try:

for(;;)
{
    Mat frame;

    cap >> frame;      // get a new frame from camera
    if (frame.empty()) // skip invalid images
         continue;

    bool ok = imwrite("C:/Users/ankit/Desktop/12.png", frame);
    // we've written the image, can go home now:
    if (ok)
        break;    
}