Feature tracking - calcOpticalFlowPyrLK??

asked 2013-11-07 11:04:19 -0500

MikeStrike gravatar image

Hello,

I use the following feature tracker: https://code.google.com/p/opencv-cookbook/source/browse/trunk/Chapter%2010/featuretracker.h?r=2

What I do not understand is how it works with the in-/output point positions in the images. If there is no prev. Image, the algorithm stores the current image (gray) in (gray_prev) and then calls

 cv::calcOpticalFlowPyrLK(gray_prev, gray, // 2 consecutive images
                        points[0], // input point position in first image
                        points[1], // output point postion in the second image
                        status,    // tracking success
                        err);      // tracking error

In the first iteration gray_prev and gray are the same and therefore all points in points[0] can be copied to points[1] - fine. Then the algrithm kicks out some points in points[1] and swaps gray_prev and gray respectively points[1] and points[0].

Which means that in the next iteration - right after calling the processing method, the keypoints in points[0] correspond to the previus frame ( gray_prev ). Now, if the number of points in points[0] is to low, new keypoints - which were found in the current image (gray) - are added

                        points[0].insert(points[0].end(),features.begin(),features.end());
                        initial.insert(initial.end(),features.begin(),features.end());

This means that we mix keypoints from both images in points[0]?! How does this work?

edit retag flag offensive close merge delete