TypeError: src2 is not a numpy array, neither a scalar
TypeError: src2 is not a numpy array, neither a scalar
我正在尝试解决一个问题,我必须将一张图像与一系列图像进行相似性比较。
for fn in image_path_list:
difference = cv2.subtract(image1, fn)
result = not np.any(difference) #if difference is all zeros it will return False
if result is True:
print("The images are the same")
else:
cv2.imwrite("result.jpg", difference)
print("the images are different")
这导致:
TypeError: src2 is not a numpy array, neither a scalar
我做错了什么? (我必须将 image1 与 image_path_list 中的所有图像进行比较)
difference = cv2.subtract(image1, fn)
这里 fn
是磁盘上图像的路径,而不是图像。你应该从磁盘上读取它。
试试这个:
image2 = cv2.imread(fn)
difference = cv2.subtract(image1, image2)
我正在尝试解决一个问题,我必须将一张图像与一系列图像进行相似性比较。
for fn in image_path_list:
difference = cv2.subtract(image1, fn)
result = not np.any(difference) #if difference is all zeros it will return False
if result is True:
print("The images are the same")
else:
cv2.imwrite("result.jpg", difference)
print("the images are different")
这导致:
TypeError: src2 is not a numpy array, neither a scalar
我做错了什么? (我必须将 image1 与 image_path_list 中的所有图像进行比较)
difference = cv2.subtract(image1, fn)
这里 fn
是磁盘上图像的路径,而不是图像。你应该从磁盘上读取它。
试试这个:
image2 = cv2.imread(fn)
difference = cv2.subtract(image1, image2)