3


I have an EMGU (openCV wrapper) program that subtracts the background from
a camera feed and extracts nice clean blobs.
Now I need something that will track these blobs and assign them with IDs.
Any suggestions/libraries ?


Thanks,
SW

2 Answers 2

4

well if you have multiple objects that you would like to track you could try a Particle Filter.

Particle filters basically "disposes" particles on the image which each have a certain weight. In each time step these weights are then updated by comparing them with the actual measured value of the object at that time. Particles with high weight will then dispose more particles in its direction (with adding a slight random part on the direction) for the next time step. After a few time steps the particles will then group around the objects measured position. That's why this method is sometimes also called Survival of the fittest method...

So this whole thing builds a circle:

Initialization  ---->      Sampling
                        >             \
                       /               >
                 Updating           Prediction
                      <                /
                       \               <
                          Association

So this provides a good method of tracking objects in a given scene. One way to do multi-object tracking would be to use this one particle filter on all the objects, which would work, but has disadvantages when you try to give IDs to the objects and also when the objects cross each other since the particle clouds might lose one object and follow another one.

To solve this you could try a Mixture-Particle-Filter (by Vermaak et al. [2003]). This one tracks each of the objects by an individual Particle filter (with of course less necessary particles).

A good paper on that can be found here: http://www.springerlink.com/content/qn4704415gx65315/ (I can also supply you with several other stuff on that if you like and if you speak German I can even give you a presentation I held about that in my university a while ago)

EDIT:

Forgot to mention: Since you try to do this in OpenCV: as far as I know there is an implementation of the Condensation algorithm (the first one where you use one particle filter on the whole image) is part of the OpenCV distribution, though it might be outdated a bit. There might be newer ways of the particle filter in OpenCV directly but if not you will find a lot of results on Google if you look for OpenCV and particle filters

Hope that helps... if not, please keep asking...

Sign up to request clarification or add additional context in comments.

Comments

2

You could simply adapt one of the EMGU CV examples that makes use of VideoSurveillance namespace:

     public partial class VideoSurveilance : Form
       {
          private static MCvFont _font = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0);
          private static Capture _cameraCapture;
          private static BlobTrackerAuto<Bgr> _tracker;
          private static IBGFGDetector<Bgr> _detector;
    
          public VideoSurveilance()
          {
             InitializeComponent();
             Run();
          }
    
          void Run()
          {
             try
             {
                _cameraCapture = new Capture();
             }
             catch (Exception e)
             {
                MessageBox.Show(e.Message);
                return;
             }
             
             _detector = new FGDetector<Bgr>(FORGROUND_DETECTOR_TYPE.FGD);
    
             _tracker = new BlobTrackerAuto<Bgr>();
    
             Application.Idle += ProcessFrame;
          }
    
          void ProcessFrame(object sender, EventArgs e)
          {
             Image<Bgr, Byte> frame = _cameraCapture.QueryFrame();
             frame._SmoothGaussian(3); //filter out noises
    
             #region use the background code book model to find the forground mask
             _detector.Update(frame);
             Image<Gray, Byte> forgroundMask = _detector.ForgroundMask;
             #endregion
    
             _tracker.Process(frame, forgroundMask);
    
             foreach (MCvBlob blob in _tracker)
             {
                frame.Draw(Rectangle.Round(blob), new Bgr(255.0, 255.0, 255.0), 2);
                frame.Draw(blob.ID.ToString(), ref _font, Point.Round(blob.Center), new Bgr(255.0, 255.0, 255.0));
             }
    
             imageBox1.Image = frame;
             imageBox2.Image = forgroundMask;
    
          }
       }

2 Comments

These are several problems with using OpenCV's BlobTrackerAuto. It only works on BGR images, it is VERY slow, and there is no way to use just for tracking blobs (without the Forground-extraction part).
I have implemented a custom approach for foreground background detection to obtain nice blobs and then coupled it with BlobTrackerAuto (you only need to implement some interface) and it works well in my scenario that consist on track a mouse swimming in a pool. The code i posted you is slow due to Foreground detector type, for example Mixture of Gaussians offer better performance. Howewer slow is a relative concept that depends on your scenario requirements

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.