Ask Your Question

Simple algorithm for tracking objects between frames

asked 2015-07-31 10:29:25 -0500

morphogencc gravatar image

Hey all,

I'm using contour finding (along with background subtraction) to pick out objects from a scene -- however, I'd like to also be able to track objects from frame to frame.

Given two frames, I'd like to be able to map objects from the new frame to objects in the old frame and keep track of the objects externally. Right now my algorithm:

  • Creates a list of all found objects in the current frame
  • For each object found in the current frame:
    • Find the object in the previous frame that is the closest to its current position
    • Check if the object is within a reasonable distance (say, 100 pixels)
    • If the object is close enough, call it the same object and update the previous object's position.
    • If the object is too far, create a new object (the object must have entered the scene)

This very simplistic algorithm gives me okay results, but I was wondering if there was a better method available in the OpenCV library. I'm not familiar with standard computer vision techniques, but I imagine there must be a better way! Any suggestions?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-07-31 11:04:44 -0500

unxnut gravatar image

You will need to search for tracking in general and will get plenty of hits inside OpenCV documentation. Beyond that, search for Kalman filter, background subtraction, keypoint descriptors, and check the sample code for those provided with OpenCV source. You may also find some tutorials on the OpenCV web site.

edit flag offensive delete link more


I've gotten plenty of hits, but I haven't found anything in the documentation that explains how a Kalman Filter or Optical Flow solves my problem. Do you know of any examples that make it clear how these solve the object tracking problem?

morphogencc gravatar imagemorphogencc ( 2015-07-31 11:57:42 -0500 )edit

This could give you an idea.

Sai Kondaveeti gravatar imageSai Kondaveeti ( 2015-07-31 13:02:51 -0500 )edit

A good tutorial on Kalman filters is found here.

unxnut gravatar imageunxnut ( 2015-07-31 17:57:45 -0500 )edit

Question Tools

1 follower


Asked: 2015-07-31 10:29:25 -0500

Seen: 999 times

Last updated: Jul 31 '15