在图像上应用cv2.pyrDown()时,我想明确指定图像的输出大小。
def gaussian_pyramid(image, scale=1.5, minSize=(30, 30)):
yield image
while True:
w = int(image.shape[1] / scale)
h = int(image.shape[0] / scale)
image = cv2.pyrDown(image, dstsize=(w, h))
if image.shape[0] < minSize[1] or image.shape[1] < minSize[0]:
break
yield image
但它会引发类似于此的错误。
OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0 && std::abs(dsize.width*2 - ssize.width) <= 2 && std::abs(dsize.height*2 - ssize.height) <= 2) in pyrDown_, file /io/opencv/modules/imgproc/src/pyramids.cpp, line 873
知道如何将图像的输出大小指定为方法参数。