当前位置:网站首页>Numpy NP tips: use OpenCV to interpolate and zoom the array to a fixed shape cv2 resize(res, dsize=(64, 64), interpolation=cv2. INTER_ CUBIC)

Numpy NP tips: use OpenCV to interpolate and zoom the array to a fixed shape cv2 resize(res, dsize=(64, 64), interpolation=cv2. INTER_ CUBIC)

2022-06-25 04:10:00 FakeOccupational

res = cv2.resize(res, dsize=(64, 64), interpolation=cv2.INTER_CUBIC)

 Insert picture description here

import cv2
 
src = cv2.imread('D:/cv2-resize-image-original.png', cv2.IMREAD_UNCHANGED)

#percent by which the image is resized
scale_percent = 50

#calculate the 50 percent of original dimensions
width = int(src.shape[1] * scale_percent / 100)
height = int(src.shape[0] * scale_percent / 100)

# dsize
dsize = (width, height)

# resize image
output = cv2.resize(src, dsize)

cv2.imwrite('D:/cv2-resize-image-50.png',output) 

cv2.error: OpenCV(4.5.2) resize.cpp:4051: error: (-215:Assertion failed) !ssize.empty() in function ‘cv::resize’

 reason : None-  Empty image  -  Show  ssize.empty()

Reference and more

https://stackoverflow.com/questions/67737650/cv2-error-opencv4-5-2-resize-cpp4051-error-215assertion-failed-ssize
https://www.w3bai.com/en-US/jquery/jquery_dimensions.html
https://pythonexamples.org/python-opencv-cv2-resize-image/

原网站

版权声明
本文为[FakeOccupational]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250145286350.html