How to do motion tracking of an object using video? [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
开发者_StackOverflow社区 Improve this questionCould someone direct me to a tutorial or guide me how to track motion of an object moving with 6 DOF. I am planing to use a video stream of a moving toy car. I want to calculate displacement and rotation angle of the toy car. I came across some research papers but couldn't find any libraries to the job.
Is there a way to do this using OpenCV or Matlab or some other freely available software?
Thank you
Tracking is a classical computer vision problem to which research is still devoted in computer science; you can quickly get a sense of the state-of-the-art in this field by checking the list of accepted papers in CVPR 2010 (which is an annual top computer vision conference) and you'll see that there is still active work being published on the topic (search for the word "tracking" within the list).
The standard processing pipeline of a solution for a tracking problem works as follows: The image is first parsed to extract meaningful descriptors that capture relevant corners and other salient features of the image. These descriptors are later fed to an on-line classifier that is trained to detect likely instances of your particular object of interest in each frame. The descriptor of your object may be known a priori, (i.e. computed off-line) from previous examples of what the object looks like, but it is usually updated in every frame by what the the system sees over time, to make the detection adaptive to the dynamic object appearance. Finally, in order to choose from a pool of possible candidates in each frame (from those that were detected), parameters such as the position and velocity of your objects are estimated with respect to previous frames using a sequential statistical model.
There is a vast computer vision literature on good image descriptors, but some of the most popular ones are SIFT, SURF, or HOG. For classification, two of the most successful methods are support vector machines or classification ensembles (e.g. boosting or random forests), and for the estimation part, most people still use Kalman filters (which is a type of sequential Markov model), particle filters or more generally density estimation models.
The specific case you described is a bit easier than the more general and difficult object-tracking problem with arbitrary camera and object motion in natural outdoor scenes, so you might be able to find some code online that could work right away in your setting, but I doubt it. As others pointed out, (and to the best of my knowledge), there is no off-the-shelf library that works right away for all sorts of objects, backgrounds and motion spaces. That said, you can probably find code for the individual components of the standard general pipeline I described above (classifiers, banks of filters/features, Markov estimation models) online.
My suggestion is, if you are interested in building a good system (i.e. one that actually works), then look at the websites of the authors of most recent papers in top annual computer vision conferences, such as CVPR, ICCV, ECCV and SIGGRAPH. They tend to have code online for their most recent work with some video examples, and this might help you get a sense of how their methods work in a real setting.
I doubt there is a program ready to use for that... at least you will have to get a couple of methods or libraries and use no so easy maths to do that. People do their thesis about that!
This is a paper I read recently:
http://cobweb.ecn.purdue.edu/RVL/Research/ModelBasedTracking/index.html
If you think is not what you are looking for then go the references only to get more ideas ;)
Maybe the KLT Tracker (Kanade Lucas Tomasi) can help you. It tells you where detected points moved between the images. The OpenCV library contains a version of the KLT Tracker but without affine conistency check (as the KLT homepage states).
If you want to try some ready-made code, there is a sample file that comes with OpenCV. In OpenCV 2.1 it's in samples/c/blobtrack.cpp and in OpenCV 2.2 it's in samples/c/blobtrack_sample.cpp. Both come with .exe files, so you can try the samples right away in case you happen to use Windows. There is an oldish site, The OpenCV Video Surveillance / Blob Tracker Facility, documenting how the code works.
The tracker in blobtrack.cpp is divided in three stages (copied from the previous link):
- A foreground/background discriminator which labels each pixel as either foreground or background.
- A blob detector which groups adjacent "foreground" pixels into blobs, flood-fill style.
- A blob tracker which assigns ID numbers to blobs and tracks their motion frame-to-frame.
blobtrack.cpp actually implements several methods for each stage, so you can try different combinations to see which one works best.
That last stage means that you can actually track multiple objects simultaneously. I've tested it on videos of vehicles moving on highways taken with a static camera and it works pretty well, if a bit slow with the best methods.
Also, you can go a long way using a simple technique called background subtraction if the background of your video is static, that is, if the only thing that changes from frame to frame is the toy car itself. But I think that will only help you as far as locating the object, not estimating its pose.
Note: I couldn't get the sample that comes with OpenCV 2.2 to work. The one that comes with OpenCV 2.1 worked fine for me.
Have a look at TLD (apparantly Matlab):
TLD is an award-winning, real-time algorithm for tracking of unknown objects in video streams. The object of interest is defined by a bounding box in a single frame. TLD simultaneously Tracks the object, Learns its appearance and Detects it whenever it appears in the video. The result is a real-time tracking that typically improves over time.
Haven't used it personally, but the demo videos are awesome.
This is the software you are looking for http://www.cabrillo.edu/~dbrown/tracker/
This articles may help inspiring you http://www.wired.com/wiredscience/2010/10/physics-of-angry-birds/
精彩评论