2013-05-03 11 views
6

Nel mio script ho il seguente codice:OpenCV parametro 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 dice:

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) 

ma secondo la documentazione:

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

tre parametri sono OK. Ho lo stesso problema con cv2.warpAffine.

risposta

14

Problema risolto. img.shape rendimenti tupla con 3 elementi, warpPerspective aspetta tuple con 2.

2

Prova questa

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

Qual è '[1 :: - 1]' significa? – tomfriwel