Practice of Particle Filter in Image Tracking Field

foreword

    Two days ago, I summed up some experience and summary of my original research on particle filter tracking on GitChat: Portal . Some chapters have been slightly edited and arranged as follows.

Introduction to Particle Filtering and Kalman Filtering

Kalman filter

    Kalman filtering can predict unknown quantities based on some known quantities, which must be approximated by Gaussian noise when disturbed. What can this thing be used for? For example, we can use it to predict the temperature of tomorrow, the day after, and several days into the future. We can use a thermometer to record a series of temperature data a few days ago as one of the reference data for our future predictions, and then we use the temperature changes throughout the year as the second reference data, and we add one to each of these two reference data. The weights combine to predict future temperatures. If the data recorded a few days ago is very close to the real temperature (after all, the thermometer is also inaccurate), we will increase its weight. Using this method, Mr. Kalman's predictions of data in the near future are still very accurate, as long as our data is only disturbed by Gaussian noise.

    For the detailed derivation process of the kalman filter, if you are interested, you can refer to the following paper. The derivation process of the kalman filter is described in detail in this paper. Reference paper: "Understanding the Basis of the Kalman Filter Via a Simple and Intuitive Derivation" can be downloaded and read directly from my network disk. Link Password: 8k07

particle filter

    The particle filter algorithm is derived from the Monte Carlo idea, that is, the probability of an event is represented by the frequency of the event. In layman's terms, particle filtering can also use some known data to predict future data, but particle filtering is not limited to Gaussian noise. In principle, particle filtering can control all nonlinear and non-Gaussian systems. Particle filtering is also widely used in various military fields.

  For example, suppose the program in the Patriot air defense missile of the US imperialists uses particle filtering. One day, San Fat had nothing to do to shoot a missile to go out to play. The missile was discovered by the satellite spy of the US imperialists when it just left the Korean territory. The satellite spy looked very nervous. Three-dimensional space, in which parameters such as the earth's atmospheric drag coefficient, gravity and so on are added. Then I sprinkled a handful of sand, and gave the sand initial momentum and a coefficient to simulate the mass and appearance of the missile. These sands began to fly from North Korea towards the US imperialists in space. When they first entered the Pacific Ocean, the Patriot missile located at the military base in Hawaii was launched, and it flew towards the center of the Pacific Ocean, because the large pile of sand in the program made up The largest and thickest track of 10 minutes later passes through a point in the center of the Pacific Ocean. After 10 minutes, the two missiles met in the center of the Pacific Ocean, and the particle filter successfully predicted the missile's trajectory.

  In the particle filtering process, X(t) is actually obtained by processing the states of a large number of particles. The five steps of writing particle filter code are as follows:
1. Initial state: simulate X(t) with a large number of particles, and the particles are uniformly distributed in the space;
2. Prediction stage: According to the state transition equation, each particle gets a predicted particle;
3 .Correction stage: evaluate the predicted particles, the closer the particles are to the real state, the greater their weight;
4. Resampling: the particles are screened according to the particle weights. There should be a small number of particles with small weights;
5. Filtering: Bring the resampled particles into the state transition equation to obtain new predicted particles, that is, step 2.

   For the detailed derivation process of Particle Filter, if you are interested, you can refer to the following paper. The derivation process of particle filter is described in detail in this paper. Reference paper: "Contour Tracking by Stochastic Propagation of Conditional Density" can be downloaded and read directly from my network disk. Link: [Portal]( https://pan.baidu.com/s/1UtmNpI54lWS-glEBKcQ_AQ
), password: dp2z.
   Of course, the functions for Kalman filtering and particle filtering have been encapsulated, and I will provide the code in the later comparison experiments.

Particle filter and Kalman filter tracking comparison experiment

  In the field of motion tracking, the importance of particle filtering and Kalman filtering will not be repeated, but they are different expressions and generalizations of Bayesian filtering.
1.1 Flow chart of comparative experiment
1.2 The coding mark point makes an approximate circular motion (non-linear)

   In this section, two sets of comparative experiments are designed to compare the pros and cons of particle filtering and Kalman filtering in tracking moving objects in nonlinear and non-Gaussian states through practical experiments, so as to select a method with higher tracking accuracy and apply it to stereo vision Dynamic measurement system to improve the running speed of the program. The target point here is the coding mark point (if you don’t understand what the coding mark point is, it will not affect the reading of subsequent articles. It just has a numerical mark for our motion point, and the center coordinate of the coding mark point is A flowchart summary of our tracked object) comparative experiment is shown in Figure 1.1.
(1) In the first group of experiments
   , select a coding mark point and fix it on a long strip of cutting board without loss of generality. Here, hold the cutting board to make the coding mark point perform approximately uniform circular motion, as shown in Figure 1.2. The three-dimensional display of its motion trajectory is shown in Figure 1.3. According to the flow chart steps shown in Figure 1.1, the error statistics between the coordinate position of the Kalman filter and the particle filter predicted coding mark point and the real motion trajectory are shown in Figure 1.4. The red dotted line in the figure represents the particle filter, and the blue dotted line represents the Kalman filter.
Figure 1.3 Schematic diagram of the circular motion of the coding mark point

Figure 1.4 Particle filter and Kalman filter tracking the coded marker points in circular motion
(2) In the second group of experiments
   , select a designed coding mark point, hold the coding mark point in the field of view of the camera to make arbitrary nonlinear and irregular motions, and the schematic diagram of the movement trajectory of the coding mark point in the experiment is shown in Figure 1.5. According to the flow chart steps shown in Figure 1.1, the error statistics between the coordinate position of the Kalman filter and the particle filter predicted coding mark point coordinates and the real coordinates are shown in Figure 1.6.

   From the above two sets of experimental results, it can be found that the red line is always below the blue line. It can be seen that the particle filter has higher tracking accuracy and better robustness for the coding mark points of nonlinear motion.
Figure 1.5 Schematic diagram of the non-linear random motion of the coding mark

Figure 1.6 Schematic diagram of coding markers for tracking nonlinear random motion

  If you need to successfully run the above two sets of experimental codes, just replace the property sheets "OpenCVDebug64.pros" and "OpenCVRelease64.props" in the project project with the opencv property sheets you configured according to the first part of the article.

Application of Particle Filter in Image Tracking Field

  In the field of image tracking, sometimes global detection of high-resolution images will cause the entire program to run too slowly, so that real-time processing cannot be achieved, which cannot meet industrial requirements. Therefore, it is necessary to use particle filtering to estimate the position of the target point in the next frame, so as to accurately reduce the region of interest (ROI) for detection. Here is an example of using a camera to track multiple encoded landmarks.
Figure 1.7 Schematic diagram of the imaging of the encoded marker points in the camera
Figure 1.8 Tracking Coded Markers Using Particle Filtering
Figure 1.9 Figure 3.9 Schematic diagram of reducing ROI and local detection

  The flow chart of using particle filter to track the coded landmarks can be summarized as shown in Figure 1.8. As shown in Figure 1.8, the original coding mark points in Figure 1.7 will no longer require global detection for each image, but reduce the ROI for detection, which greatly improves the running speed of the program, as shown in Figure 1.9.

summary

  The above mainly briefly expounds the principle of particle filter and Kalman filter, and focuses on the comparison experiment of the tracking performance of particle filter and Kalman filter, and analyzes the application of particle filter in the image field in the form of a case.

postscript

  A few days ago, I accidentally found that an article I once wrote was included and published on the CSDN platform: Those valuable literature resources download experience summary , many people left a message, saying that they have benefited a lot. For me, the joy was beyond words. Sincerely hope that we can learn together with you and make progress with each other.

Personal public account

write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326357111&siteId=291194637
Recommended