Remove Opencv Image Size Limitation
I am loading in a very large image (60,000 x 80,000 pixels) and am exceeding the max pixels I can load: cv2.error: OpenCV(4.2.0) /Users/travis/build/skvark/opencv-python/opencv/mod
Solution 1:
You have to modify the openCV source files and then compile it your own.
EDIT: You can also modify environment variables
export CV_IO_MAX_IMAGE_PIXELS=1099511627776
Solution 2:
For my problem I should have specified it was a .tif file (NOTE most large images will be in this file format anyway). In which case a very easy way to load it in to a numpy array (so it can then work with OpenCV) is with the package tifffile.
pip install tifffile as tifi
This will install it in your python environment.
import tifffile as tifiimg= tifi.imread("VeryLargeFile.tif")
From here you can use it as you would with any numpy array and it is fully compatible with OpenCV etc.
Solution 3:
Adding the following to your program should fix the issue in python opencv.
import os
os.environ["OPENCV_IO_MAX_IMAGE_PIXELS"] = str(pow(2,40))
import cv2
Post a Comment for "Remove Opencv Image Size Limitation"