opencv / opencv-python

Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.
https://pypi.org/project/opencv-python/
MIT License
4.54k stars 851 forks source link

PYTHON cv2.resize Error “(-215:Assertion failed) !dsize.empty()” #450

Open josele69 opened 3 years ago

josele69 commented 3 years ago

I am trying to resize an image with cv2.resize function in PYTHON3 and I get the following error:

error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\imgproc\src\resize.cpp:3688: error: (-215:Assertion failed) !dsize.empty() in function 'cv::hal::resize'

My images are uint16 arrays:

img_ms.shape (4, 57, 62)

img_pan.shape (1, 1140, 1240)

The sample function I am using inside an image pansharpening script is:

downsampled_img_pan = cv2.resize(img_pan, (img_ms.shape[2], img_ms.shape[1]), interpolation = cv2.INTER_AREA)[:, :, np.newaxis]

Thanks!

sanketc001 commented 3 years ago

I dont think will work since you cannot convert a 4D img into 1D like this.

apple55bc commented 1 year ago

last dim must be lower than 512. but 1240 > 512