我想用“cv2.resize”比较两个图像,因为我有不同大小的图像。 但它显示出一些错误
(略)资料来源:
def img_compare(passA, passB):
imageA = cv2.imread(passA)
imageB = cv2.imread(passB)
print (imageA.shape) # for debug
print (imageB.shape) # for debug
imageA = cv2.resize(imageA, imageB.shape)
控制台:
(728, 1034, 3)
(721, 1020, 3)
Traceback (most recent call last):
File "comp.py", line 156, in <module>
throw_compare()
File "comp.py", line 150, in throw_compare
img_compare(passA, passB)
File "comp.py", line 89, in img_compare
imageA = cv2.resize(imageA, imageB.shape)
cv2.error: OpenCV(4.5.3) :-1: error: (-5:Bad argument) in function 'resize'
> Overload resolution failed:
> - Can't parse 'dsize'. Expected sequence length 2, got 3
> - Can't parse 'dsize'. Expected sequence length 2, got 3
如何修复它们
其中一条评论已经回答了这个问题。但是为了更清楚,您需要在
cv2.resize
参数中传递一个(宽度、高度)元组。下面是一个工作示例:希望这有帮助!干杯此外,由于这是一个基本问题,我建议在发布之前请检查OpenCV文档Here's文档中的一个示例
相关问题 更多 >
编程相关推荐