Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python: Pyramids not working for calcOpticalFlowPyrLK

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)
         maxLevel=3,
         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)

Error:

kp2, st, err = cv2.calcOpticalFlowPyrLK(image_ref, image_cur, px_ref, None, **lk_params)
TypeError: prevImg is not a numerical tuple