在我的脚本中有以下代码:
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/