opencv imwrite unable to save images >40MP [closed]
Hi,
I have a camera capable of 41.5MP. When I try to save an image from the camera it gets created, only that the image is 0KB in size, there is no error caught. If I save a region from the image then the image is saved correctly (as in the code below). Is there some limit to image size above which the image cannot be saved? (I am using version 4.0.1 opencv on Windows 10 and VC++ 17)
cv::Mat im = grabCVImage();
int s = 1200;
roi.x = s;
roi.y = s;
roi.width = s;
roi.height = s;
try {
imwrite("C:\\Users\\Watts\\Pictures\\alpha.png", im(roi));
}
catch (std::runtime_error& ex) {
fprintf(stderr, "Exception converting image to PNG format: %s\n", ex.what());
return 1;
}
default size limit is 2^30 (CV_IO_MAX_IMAGE_PIXELS system variable)
But 2^30 or 1 Gigapixel is much larger than 41.5MP. It doesn't explain why the image does not save
Problem is not imwritte try :
It will works.
Check im size, im depth, and im type. Change path, try im(oi).clone() ...
Yes, strange, I can save a newly created image of the same dimensions OK.
And when I call
imshow("im", im);
it shows the image perfectly. Then the imwrite() afterwards gives an image of 0KB. Also when an roi of the image was saved it worked ok.