# An Automatic Counting Algorithm for Topographic Maps Based on Videos for Map Management
## 3 Materials and Methods
### The Proposed Fusion Window Counting Algorithm
#### 3.2.1 Deformable Parts Model Based on Fast Feature Pyramids
The general feature pyramid is constructed by scaling the image \(I\) to scale \(s\) and then calculating the FHOG features of the image \(I_{s}\); that is, \(C_{s}=\Omega(\mathrm{S}(I,s))\), where \(C=\Omega(I)\) denotes the feature extraction function, and \(\mathrm{S}\) denotes the sampling function. The fast feature pyramid selects a benchmark scale (\(s\in\{1,0.5,0.25,\cdots\}\)) in each octave and calculates features by using the general feature pyramid method \(C_{s}=\Omega(\mathrm{S}(I,s)),s\in\{1,0.5,0.25,\cdots\}\) for feature extraction at the key scales. Through the features of the key scales, the features at the adjacent scales are estimated using the approximate estimation method \(C_{s}\approx\mathrm{S}(C_{s},s/s^{\prime})(s/s^{\prime})^{-\Lambda_{\Omega}}\), where \(s^{\prime}\) is the nearest scale to \(s\). The constant coefficient \(\lambda_{\Omega}\) needs to be estimated by the training samples in advance based on specific features, and the coefficient \(\lambda_{\Omega}\) of the FHOGModel matching  
The DPM algorithm adopts the sliding window method for model matching. At first, the overall convolution operation of the pyramid is performed using the root filter, and the response value of the root filter position of the level is obtained as:  
\[R_{0,I}(x_{0},y_{0})=\mathbf{F}_{0}\cdot\mathbf{\Phi}(H,(x,y,I)) \tag{3}\]  
where \((x_{0},y_{0})\) is the coordinate of the root filter in its level, \(H\) is the feature pyramid, \(p(x,y,I)\) is the position of level \(I\) in the specified pyramid, and \(\mathbf{\Phi}(x)\) is the feature vector at \(x\) in the image. Similarly, the response value of the \(i\)th part filter at the \(l\)th level of the feature pyramid can be obtained, but it should be considered that it has the coordinate offset dx, dy relative to the root filter:  
\[R_{i,j}(x_{0}+dx,y_{0}+dy)=\mathbf{F}_{i}\cdot\mathbf{\Phi}(H,(x_{0}+dx,y_{0}+ dy,I)) \tag{4}\]  
After calculating these filter response values, they are converted so that they have spatial uncertainty. This transformation can extend the filter's high scores to adjacent positions while also considering the deformation costs:  
\[D_{i,j}(x,y)=\max\limits_{dx,dy}(R_{i,j}(x+dx,y+dy)-d_{i}\cdot\mathbf{\Phi}_{d} (dx,dy)) \tag{5}\]  
where the \(D_{i,j}(x,y)\) value means the maximum contribution to the root position score when the anchor of the \(i\)th part is placed at the location \((x,y)\) in level \(l\). Then, the synthesis score for each level of the root position can be obtained as the root filter response value for that level plus the response value of the part filter after transformation and subsampling, minus the deformation cost of this position relative to the root filter, plus the deviation \(b\):  
\[Score(x_{0},y_{0},I_{0})=R_{0,I_{0}}(x_{0},y_{0})+\sum\limits_{i=1}^{n}D_{i,I_ {0}-\lambda}(2(x_{0},y_{0})+v_{i})+b \tag{6}\]  
Figure 7: Schematic diagram of the fast feature pyramid: (**a**) normal computation method of FHOG features; (**b**) approximate computation method of FHOG features. In the process of calculating \(D_{i,j}\), we can also calculate the optimal position of the part--that is, the function of the anchor coordinates. After finding a root position \((x_{0},y_{0},l_{0})\) with a high score, the corresponding optimal position of the part can be found as follows:  
\[P_{i,j}(x,y)=arg\max_{dx,dy}\bigl{(}R_{i,j}(x+dx,y+dy)-d_{i}\cdot\Phi_{d}(dx,dy) \bigr{)} \tag{7}\]  
Finally, the score of each window is calculated; then, the threshold is determined based on the training data. When the score is greater than the threshold, the window is considered to contain the mechanical wheel, and the position of the window in the image is marked with a rectangular box. After model matching, each frame  
We selected the sum of the modulus of gray difference (SMD) function, which is most applicable to the images in this study [31].