2013-05-03 37 views
6

私のスクリプトでは、私は次のコードを持っている:OpenCVのwarpPerspectiveパラメータ数

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 

3つのパラメータはOKです。 cv2.warpAffineと同じ問題があります。

答えて

14

問題を解決しました。 img.shapeリターンは3つの要素でタプル、warpPerspectiveは2

2

でタプルを期待 `[1 :: - 1]これは何

finished = cv2.warpPerspective(img, transform, img.shape[1::-1]) 
+0

を試してみてください'意味ですか? – tomfriwel

関連する問題