# Moving Object Tracking and Its Application to an Indoor Dual-Robot Path
## 2 Image Processing
### Mean Shift Tracking
\begin{array}{ll}\
abla f(x)&=\frac{2\sum\limits_{i=1}^{n}\left(x_{i}-x \right)g(\parallel\frac{x_{i}-x}{h}\parallel^{2})w(x_{i})}{h^{d}\sum\limits_{i= 1}^{n}w(x_{i})}\\ &=\frac{2}{h^{2}}\left[\frac{\sum\limits_{i=1}^{n}g(\parallel\frac{x_{i}-x}{h} \parallel^{2})w(x_{i})}{h^{d}\sum\limits_{i=1}^{n}w(x_{i})}\right]\left[\frac{ \sum\limits_{i=1}^{n}\left(x_{i}-x\right)g(\parallel\frac{x_{i}-x}{h} \parallel^{2})w(x_{i})}{\sum\limits_{i=1}^{n}g(\parallel\frac{x_{i}-x}{h} \parallel^{2})w(x_{i})}\right]\end{array} . \tag{13}\]  
The average motion vector is:  
\[M(x)=\left[ \begin{array}{c}\sum\limits_{i=1}^{n}x_{i}g(\parallel\frac{x_{i}- x}{h}\parallel^{2})w(x_{i})\\ \sum\limits_{i=1}^{n}g(\parallel\frac{x_{i}-x}{h}\parallel^{2})w(x_{i}) \end{array} -x\right]. \tag{14}\]  
An example of the mean shift method is shown in Figure 6.  
Using the Epanechnikov kernel average displacement vector with the average maximum Bhattacharyya coefficient simplifies the computation, so we can calculate the average displacement and find the pattern image that has the greatest similarity to the candidate image. This method can quickly and effectively identify the image with the most similar moving object candidate, and track the image. Procedures of the mean shift are shown as follows:  
Step 1: Calculate the color image density of the patterns. Step 2: Calculate the color image density of the candidate. Step 3: Substitute the color image density (patterns and candidate) into Equation (6) and obtain the Bhattacharyya coefficient at \(y_{0}\). Step 4: Obtain the \(w(x_{i})\) weights using Equation (10). Figure 6: Steps for finding the highest density of color: (**a**) Search high color density; (**b**) search high color density again; (**c**) reach center of mass. Step 5: From \(M(y_{0})=\left[\begin{array}{c}\sum\limits_{i=1}^{n}x_{i}g(\left\|\frac{x_{i}-y_{ 0}}{h}\right\|^{2})w(x_{i})\\ \sum\limits_{i=1}^{n}g(\left\|\frac{x_{i}-y_{0}}{h}\right\|^{2})w(x_{i})\\ y_{1}=\left[ \begin{array}{c}\sum\limits_{i=1}^{n}x_{i}g(\left\|\frac{x_{i}-y_{ 0}}{h}\right\|^{2})w(x_{i})\\ \sum\limits_{i=1}^{n}g(\left\|\frac{x_{i}-y_{0}}{h}\right\|^{2})w(x_{i})\\ \end{array} \right].\)  
Step 6: Use new point \(y_{1}\) to update \(\left\{p(u,y_{1})\right\}_{u=1..m}\) and \(\rho(y)\). Step 7: If \(\left[p(u,y_{1}),q(u)\right]<\rho[p(u,y_{0}),q(u)]\), revise \(y_{1}=\frac{1}{2}(y_{0}+y_{1})\). Step 8: If \(\parallel(y_{1}-y_{0})\parallel<\varepsilon\), stop iteration, otherwise update \(y_{0}\) and let \(y_{0}=y_{1}\) and return to Step 2. Through iteration of the above steps, we can calculate the similarity to the highest candidate image to achieve effective tracking. Figure 7 shows an example of a static background with a moving object. Figure 8 shows an example of a dynamic background with a moving object. Figure 7: Steps for mean shift tracking process against a static background: (**a**) Find the object; (**b**) the object moves to the right side; (**c**) search high color density; (**d**) catch the object; (**e**) the object moves forward; (**f**) keep tracking the object.