gpt4 book ai didi

python - opencv warpPerspective参数计数

转载 作者:太空狗 更新时间:2023-10-29 19:36:01 26 4
gpt4 key购买 nike

在我的脚本中有以下代码:

src = numpy.array(cornersSheet, numpy.float32)
dst = numpy.array(cornersDesired, numpy.float32)
transform = cv2.getPerspectiveTransform(src,dst)
finished = cv2.warpPerspective(img, transform, img.shape)

Python 说:

Traceback (most recent call last):
File "./script.py", line 138, in <module>
finished = cv2.warpPerspective(img, transform, img.shape)
TypeError: function takes exactly 2 arguments (3 given)

但根据文档:

    Python: cv2.warpPerspective(src, M, dsize[, dst[, flags[, borderMode[, borderValue]]]]) → dst

三个参数就OK了。我对 cv2.warpAffine 也有同样的问题。

最佳答案

问题解决了。 img.shape 返回包含 3 个元素的元组,warpPerspective 期望包含 2 个元素的元组。

关于python - opencv warpPerspective参数计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16352962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com