TypeError:dst不是numpy数组,也不是标量大小的jpg python

TypeError:dst不是numpy数组,也不是标量大小的jpg python,python,numpy,Python,Numpy,我试图调整图像的大小以进行进一步的透视处理,但我遇到了这个错误 File "/home/passerin/Documents/tesis/Project/test/scanner2/scan2.py", line 79, in resize resized = cv2.resize(img, (height, width), interpolation) TypeError: dst is not a numpy array, neither a scalar 这是密码 # load an i

我试图调整图像的大小以进行进一步的透视处理,但我遇到了这个错误

File "/home/passerin/Documents/tesis/Project/test/scanner2/scan2.py", line 79, in resize
resized = cv2.resize(img, (height, width), interpolation)
TypeError: dst is not a numpy array, neither a scalar
这是密码

# load an image
flat_object=cv2.imread("/home/passerin/Documents/tesis/Project/test/scanner2/images/personal-foto-5.png")
# resize the image
flat_object_resized = resize(flat_object, height=600)
# make a copy
flat_object_resized_copy = flat_object.copy()
#convert to HSV color scheme
flat_object_resized_hsv = cv2.cvtColor(flat_object_resized_copy, 
cv2.COLOR_BGR2HSV)
# split HSV to three chanels
hue, saturation, value = cv2.split(flat_object_resized_hsv)
这就是显示错误的地方

def resize(img, width=None, height=None, interpolation=cv2.INTER_AREA):
    global ratio
    w, h, _ = img.shape

    if width is None and height is None:
        return img
    elif width is None:
        ratio = height / h
        width = int(w * ratio)
        # print(width)
        resized = cv2.resize(img, (height, width), interpolation)
        return resized
    else:
        ratio = width / w
        height = int(h * ratio)
        # print(height)
        resized = cv2.resize(img, (height, width), interpolation)
        return resized

您正在使用位置参数进行调用,但根据您遗漏了一些参数-它认为您的第三个位置参数用于
dst
参数。即使参数/参数是可选的,如果不提供关键字,函数也希望它们按照argspec中给出的顺序。尝试使用关键字参数调用它

cv2.resize(src = img, dsize = (height, width), interpolation = interpolation)
或者只是

cv2.resize(img, (height, width), interpolation = interpolation)

第二次世界大战的答案,它就像一个符咒!我是python新手,所以这类事情经常发生: