Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Feature tracking using optical flow

I found a similar question in the forum. But the answer in there does not answer my question.

  • If I do feature detection (goodFeaturesToTrack) only once on the first image, and then use optical flow (calcOpticalFlowPyrLK) to track these features, the problem is: only the features detected on the first image can be tracked. When these features go beyond of the image, there would be no features to track.

  • If I do feature detection for every new image, the feature tracking is not stable, because the feature detected last time may not be detected this time.

I am using optical flow for 3D reconstruction. So I'm not interested in tracking what features, instead, I only care whether features in the field of view can be tracked stably. To summarize, my question is: how can I use optical flow to track old features, and in the meantime add new image features that come into the field of view and remove old features that go beyond the field of view?

like image 291
Shiyu Avatar asked Apr 15 '12 03:04

Shiyu


People also ask

What is optical flow used for?

Optical flow is a technique used to describe image motion. It is usually applied to a series of images that have a small time step between them, for example, video frames. Optical flow calculates a velocity for points within the images, and provides an estimation of where points could be in the next image sequence.

What is optical flow in object detection?

Optical flow or optic flow is the pattern of apparent motion of objects, surfaces, and edges in a visual scene caused by the relative motion between an observer and a scene. Optical flow can also be defined as the distribution of apparent velocities of movement of brightness pattern in an image.

How does optical flow sensor work?

This sensor is based on the idea of optical mouse (image sensor). It senses the image (camera sensor) of a surface or an object by taking very large number of images (frames) in short time. When the position of the object change the corresponding pixels position change.

What is optical flow on a drone?

“Optic flow is the apparent motion of objects caused by your own motion; as you descend to the ground a downward-pointing camera will see objects on the ground looming larger as it approaches them,” he explained.


2 Answers

Several approaches are possible. A good method goes like this:

  1. in Frame 1 detect N features, this is the Keyframe m=1
  2. in Frame k track the features by optical flow
  3. in Frame k if the number of successfully tracked features drops under N/2:
    • this frame is the keyframe m+1
    • compute the homography or the fundamental matrix describing the motion between the keyframes m and m+1
    • detect N features and discard the old ones
    • k := k+1 go to 2

In this method basically you estimate the camera motion between the last two keyframes.

Since you didn't mention what approach is used for 3D reconstruction I assumed either H or F are computed to estimated motion first. To estimate them accurately the baseline between the keyframes should be as wide as possible. In general, the best strategy is take into account the rough motion model of the camera. If the camera is held by hand a different strategy should be used compared to when the camera is fixed on the top of a car or a robot. I can provide a minimal working example in Python if that helps, let me know.

like image 85
fireant Avatar answered Sep 24 '22 13:09

fireant


Just for documentation purposes, there are several good GPU / C++ implementations of optical flow tracking. Your code may be better for your purposes, but if all you need is the output data of the tracks, consider checking any of the following sources: here, here, or here.

like image 26
ely Avatar answered Sep 22 '22 13:09

ely