read and display image of large size
I have images of size 1.1 - 1.5 G that need to be loaded and processed, then displayed. When I load the image, I get the following error:
OpenCV: terminate handler is called! The last OpenCV error is: OpenCV(4.1.0-pre) Error: Assertion failed (pixels <= CV_IO_MAX_IMAGE_PIXELS) in cv::validateInputImageSize, file C:\openCV\opencv\modules\imgcodecs\src\loadsave.cpp, line 75
I try to change the default size settings in the code but still get error. What should I do to load images of such size? My computer has plenty of memory, even matlab can load the image without issue.
Thanks in advance
what have you tried?
"I try to change the default size settings in the code" no you must set CV_IO_MAX_IMAGE_PIXELS) variable in shell and run your program
Hi,
I did both, in shell to set an environment variable and in source. none of them works.
without any code or method I cannot reproduce your problem. Opencv version platform ?
Hi,
My code is very simple to reproduce the problem: int main(int argc, char** argv) { // ... Mat image; image = imread(argv[1], IMREAD_COLOR); // Read the file namedWindow("Display window", WINDOW_NORMAL); resizeWindow("Display frame", 1024, 1024); imshow("Display window", image); // Show our image inside it. waitKey(0); // Wait for a keystrok
before running, at command line, set CV_IO_MAX_IMAGE_PIXELS=18500000000
I use the master branch head.
Thanks
oops I made a mistake
Hi, Thanks a lot for you spending effort on this issue. I dig a little bit deeper: 1. When I set the environment variable CV_IO_MAX_IMAGE_PIXELS to very large number, it saturates to 1073741824 on my Windows 10.
2. If I modify the source code to change
static const size_t CV_IO_MAX_IMAGE_PIXELS = utils::getConfigurationParameterSizeT("OPENCV_IO_MAX_IMAGE_PIXELS", 1 << 30);
to
static const size_t CV_IO_MAX_IMAGE_PIXELS = utils::getConfigurationParameterSizeT("OPENCV_IO_MAX_IMAGE_PIXELS", 1 << 34);
The CV_IO_MAX_IMAGE_PIXELS will be zero! It appears that the system limits to 32 bit, but I don't know. I am very new to openCV and just getting start to get my feet wet.
Thanks again.
Opencv version platform ? and don't change source code
OpenCV version: 4.1.0-pre OpenCV VCS version: 4.0.1-413-g17ad33c91 Windows 10, Visual Studio pro 15.9.8
thank you so much @lzlu123 i solved my problem