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);
}
2 | No.2 Revision |
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;
}