opencv warpPerspective参数计数

Ada*_*hon 9 python opencv numpy

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

src = numpy.array(cornersSheet, numpy.float32)
dst = numpy.array(cornersDesired, numpy.float32)
transform = cv2.getPerspectiveTransform(src,dst)
finished = cv2.warpPerspective(img, transform, img.shape)
Run Code Online (Sandbox Code Playgroud)

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)
Run Code Online (Sandbox Code Playgroud)

但根据文件:

    Python: cv2.warpPerspective(src, M, dsize[, dst[, flags[, borderMode[, borderValue]]]]) ? dst
Run Code Online (Sandbox Code Playgroud)

三个参数都可以.我有同样的问题cv2.warpAffine.

Ada*_*hon 17

问题解决了.img.shape返回带有3个元素的元组,warpPerspective预计元组为2.


小智 5

尝试这个

finished = cv2.warpPerspective(img, transform, img.shape[1::-1])
Run Code Online (Sandbox Code Playgroud)