Introduction to particle filter

Source: Internet
Author: User

We always think that particle filtering is a good thing. Every time we try to read the literature, we can't see the complex mathematical symbols. A chance to discover Rob Hess (http://web.engr.oregonstate.edu /~ Hess/) to implement this particle filter. Starting with the code, we can understand the principles of particle filter. According to the introduction of particle filter on Wikipedia (http://en.wikipedia.org/wiki/Particle_filter), particle filter has many variants, Rob Hess implementation of this should be the most basic one, sampling importance resampling
(SIR), sampling based on importance. The following is my rough understanding of the algorithm principle of particle filter for Object Tracking:

1) initialization stage-extract tracking target features

In this phase, you need to manually specify the tracking target, and the program calculates the characteristics of the Tracking target. For example, you can use the color features of the target. Specific to rob Hess code, you need to manually drag a tracking area at the beginning, and then the program automatically calculates the histogram of the hue space in the area, that is, the target feature. The Histogram can be expressed by a vector, so the target feature is a vector V of N * 1.

2) search phase-dog placement

Well, we have mastered the characteristics of the target. Below we release a lot of dogs to search for the target object. Here the dog is the particle. There are many ways to release a dog. For example, a) Uniform placement: uniformly Scattering Particles (Uniform Distribution) on the entire image plane; B) Moving them near the target obtained in the previous frame according to Gaussian distribution, it can be understood that more places are placed near the target, and less places are placed away from the target. Rob Hess's Code uses the latter method. How can a dog search for a target after it is released? It is the target feature (color histogram, vector v) obtained in the initialization phase ). Each dog calculates the color feature of the image at its position, obtains a color histogram and vector VI, and computes the similarity between the histogram and the target histogram. Similarity has multiple measurements. The simplest one is to calculate sum (ABS (Vi-V )). each dog calculates the similarity and then normalize it again, so that the similarity obtained by all dogs is equal to 1.

3) decision-making stage

A clever dog we put out reported to us, "the similarity between the image of No. 1 dog and the target is 0.3", and "the similarity between the image of No. 2 dog and the target is 0.02 ", "the similarity between the image at DOG 3 and the target is 0.0003," and "the similarity between the image at dog n and the target is 0.013 "... so where is the goal most likely? Let's make a weighted average. Set the pixel coordinate of the Image of dog n to (Xn, yn). The reported similarity is wn, so the most likely pixel coordinate of the target x = sum (XN * wn ), y = sum (YN * wn ).

4) resampling

Since we are tracking the target, in general, the target is running around in disorder. Where can the target be in a new image? Let's search for a dog. But how should we put a dog? Let's review the report from the dogs. "The similarity between the image of No. 1 dog and the target is 0.3", "the similarity between the image of No. 2 dog and the target is 0.02", and "the similarity between the image and the target of No. 3 dog is 0.0003 ", "the similarity between the image and the target of dog n is 0.013 "... according to the reports of all dogs, the similarity between dogs 1 and 3 is the highest, and the similarity between dogs 3 is the lowest. Therefore, we need to re-distribute police forces, we put more dogs in the dog with the highest similarity, less dogs in the dog with the lowest similarity, and even recall the original dog. This is sampling.
Importance resampling, re-sampling based on importance (more important ).

(2)-> (3)-> (4)-> (2) if the loop is repeated, the dynamic tracking of the target is completed.

 

According to my rough understanding, the core idea of particle filtering is random sampling + importance sampling. Since I don't know where the target is, I should randomly scatter the particles. After scattering the particles, the importance of each particle is calculated based on the feature similarity. Then, the particles are scattered in important places, and less scattered in unimportant places. Therefore, compared with Monte Carlo filtering, particle filtering requires less computation. This idea coincides with the ransac algorithm. The idea of ransac is also (for example, it is used in the simplest linear fitting). Since I don't know what the linear equation is, I will calculate a straight line first from two random points, then let's see how many points match my line. Which line can obtain the support of the most points, and which line is the target line. The idea is very simple, but it works well.

 

Let's talk about the code. Rob Hess's Code seems to be on Linux. I changed it slightly so that Windows + vs2008 can run. In track1.c, the main function is used to process the attached video by default. Of course, you can easily change it to input the video from the camera (cvcapturefromcam ). I used opencv2.0 and did not test versions earlier than 2.0. After the program starts, after reading the first image, you need to drag the target area of the tracking with the mouse (then press Enter ). The tracking area is faster than the hour. When the tracking area is large, it becomes very difficult. The Code also requires the support of The GSL library. I use gsl1.8. The following provides the download of the gsl1.8 Installation File. Here is all the Code and related vs2008 project files

Reprinted: http://www.cnblogs.com/yangyangcv/archive/2010/05/23/1742263.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.