Motion tracking using Emgu CV (or OpenCV)

Kaveh Shahbazian picture Kaveh Shahbazian · Jun 13, 2011 · Viewed 11.1k times · Source

How can I do motion tracking using Emgu CV or OpenCV? What are different ways of doing it?

I want to track objects against a fixed background.

Best Regards

Answer

Matyas picture Matyas · Jun 13, 2011

Since I don't know Emgu CV, I would recommend OpenCV. I'd suggest you use the Lucas Kanade tracking (optical flow). You track objects by doing the following:

  1. Read an image from source (webcam/video file etc.)
  2. Preprocess it (optional, but can be proven useful)
  3. Extract from a region (e.g. from the head of a person) points to track. You can do this automatically using the cvGoodFeaturesToTrack method.
  4. Then you can track these points with cvCalcOpticalFlowPyrLK, which will give you the new positions of your tracked points.

See a better tutorial here.

If you want to understand the concepts behind these functions I would highly recommend reading Learning OpenCV - unfortunately the linked book is only a preview, with missing pages.

Anyway I am sure you can think of a place where you can get this book ;).