Ask Your Question
0

read and display image of large size

asked 2019-03-19 11:22:30 -0500

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

edit retag flag offensive close merge delete

Comments

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

LBerger gravatar imageLBerger ( 2019-03-19 11:27:35 -0500 )edit

Hi,

I did both, in shell to set an environment variable and in source. none of them works.

lzlu123 gravatar imagelzlu123 ( 2019-03-19 13:29:36 -0500 )edit

without any code or method I cannot reproduce your problem. Opencv version platform ?

LBerger gravatar imageLBerger ( 2019-03-19 13:58:28 -0500 )edit

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

lzlu123 gravatar imagelzlu123 ( 2019-03-19 14:30:58 -0500 )edit

before running, at command line, set CV_IO_MAX_IMAGE_PIXELS=18500000000

I use the master branch head.

Thanks

lzlu123 gravatar imagelzlu123 ( 2019-03-19 14:33:21 -0500 )edit

oops I made a mistake

LBerger gravatar imageLBerger ( 2019-03-19 14:38:54 -0500 )edit

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.

lzlu123 gravatar imagelzlu123 ( 2019-03-19 15:31:47 -0500 )edit

Opencv version platform ? and don't change source code

LBerger gravatar imageLBerger ( 2019-03-19 15:41:00 -0500 )edit

OpenCV version: 4.1.0-pre OpenCV VCS version: 4.0.1-413-g17ad33c91 Windows 10, Visual Studio pro 15.9.8

lzlu123 gravatar imagelzlu123 ( 2019-03-20 08:10:00 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2019-03-19 14:40:11 -0500

LBerger gravatar image

You must set OPENCV_IO_MAX_IMAGE_PIXELS before your script

Microsoft Windows [version 10.0.17763.379]
(c) 2018 Microsoft Corporation. Tous droits réservés.

C:\Users\Laurent>set OPENCV_IO_MAX_IMAGE_PIXELS=50000

C:\Users\Laurent>"f:\Program Files\Python\python.exe"
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2 as cv
>>> cv.imread("g:/lib/opencv/samples/data/lena.jpg")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
cv2.error: OpenCV(4.1.0-pre) G:\Lib\opencv\modules\imgcodecs\src\loadsave.cpp:75: error: (-215:Assertion failed) pixels <= CV_IO_MAX_IMAGE_PIXELS in function 'cv::validateInputImageSize'
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-03-19 11:22:30 -0500

Seen: 537 times

Last updated: Mar 19