1 | initial version |
Hello,
This is a very late answer to your problem, you probably solved it yourself already. I thought it might be of help for others (like me) who are struggling with this method in OpenCV.
It seems to me that you do NOT need to use the function cv2.buildOpticalFlowPyramid() AT ALL to work with pyramids. The parameter maxLevel in cv2.OpticalFlowPyrLK() is used to determine the maximum level of the pyramid intrinsically built by the function.
This is quite confusing in the documentation of OpenCV, I hope they will change it soon. Took me way too long to figure this out:
It seems just wrong how it is written there.
In conclusion, just change this line:
res = cv2.calcOpticalFlowPyrLK(pyr1, pyr2, prev_features)
to this one:
res = cv2.calcOpticalFlowPyrLK(im, im2, prev_features, maxLevel = 10)
and you are using pyramids in your optical flow (up to 11 levels).
Best wishes!