Python: Pyramids not working for calcOpticalFlowPyrLK

asked 2016-09-05 12:34:24 -0500

jads_96 gravatar image

System information (version)

OpenCV => 3.1-dev

Operating System / Platform => Windows 64 Bit

Compiler => Visual Studio 2015

Detailed description:

When trying to run pyramids as the input for the cv2.calcOpticalFlowPyrLK function the program gives out an error. when I run the cv2.buildOpticalFlowPyramid method it returns a pyramid, without any errors but as soon as I use it as input it doesn't run.

Steps to reproduce:

lk_params = dict(winSize=(21, 21),  # Parameters used for cv2.calcOpticalFlowPyrLK (KLT tracker)
         criteria=(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 30, 0.01))

def KLT_featureTracking(image_ref, image_cur, px_ref):

   image_ref = cv2.buildOpticalFlowPyramid(image_ref, (512, 512), 2)
   image_cur = cv2.buildOpticalFlowPyramid(image_cur, (512, 512), 2)

   kp2, st, err = cv2.calcOpticalFlowPyrLK(image_ref, image_cur, px_ref, None, **lk_params)
   kp1, st, err = cv2.calcOpticalFlowPyrLK(image_cur, image_ref, kp2, None, **lk_params)


kp2, st, err = cv2.calcOpticalFlowPyrLK(image_ref, image_cur, px_ref, None, **lk_params)
TypeError: prevImg is not a numerical tuple
edit retag flag offensive close merge delete


did those pyramids actually work from anywhere, ever ?

berak gravatar imageberak ( 2016-09-05 12:39:43 -0500 )edit

what do you mean from anywhere? If I input an image to buildOpticalFlowPyramid it returns the image without error, the problem is when I input the pyramid to the calcOptFlowPyrLK

jads_96 gravatar imagejads_96 ( 2016-09-05 12:42:30 -0500 )edit