1 | initial version |
iirc, older opencv versions had sometmes problems writing png or jpeg files, when there was no compression info supplied, so for png:
vector<int> flags;
flags.push_back(CV_IMWRITE_PNG_COMPRESSION);
flags.push_back(9); // [0-9]
imwrite("C:\\Frames\\frame.png",frame,flags);
or jpeg:
vector<int> flags;
flags.push_back(CV_IMWRITE_JPEG_QUALITY);
flags.push_back(99); // [0-99]
imwrite("C:\\Frames\\frame.jpg",frame,flags);
also, doublecheck if your frame was valid:
cap >> frame;
if ( ! frame.empty() )
{
// save to disk
}