# A Systematic Deep Learning Based Overhead Tracking and Counting System Using RGB-D Remote Cameras
## 3 The Proposed System Methodology
### Head and Shoulders Detection  
Hough Circular Gradient Transform (HCGT) is a technique that detects the circles by first passing an imperfect image to the edge detection phase. In our proposed work the HCGT technique is used for detecting heads in an image by first finding the edges of an image. These edges will further help to find the circular heads in an image by considering the local gradient. The circle in an image is defined using Equation (3);  
\[(x-p)^{2}+(y-q)^{2}=r^{2} \tag{3}\]  
where \(p\) and \(q\) are the circle center coordinate points, \(r\) is the radius and x and y are the arbitrary edge points. Because the dataset images are taken from the top view cameras the heads are more likely to appear circular. Circular candidates are detected in the Hough parameter space by voting and selecting the local maxima in an accumulator matrix. The location of each non-zero pixel is identified to get the centers of the heads from the points in an accumulator that are above the threshold and larger than their candidate neighbors. These candidate centers are then sorted in descending order by their accumulator values, causing the most supported pixels to appear first. All the non-zero pixels are considered for every center. These pixels are then sorted according to the minimum distance from the centers of the circles. Considering the smallest distance to the largest distance, the radius of the circle that is less than the given threshold _thresh_R_ is selected. The center that provides sufficient support for the non-zero pixels on the edge of the image is kept and provides sufficient distance from a previously selected center. Thus, the HCGT technique can divide the problem of finding the circular head into two sub-stages. First, the candidate centers are found and then the appropriate circle radius is found. A 2D array is required to store the votes of each edge point whereas the distance between each point is accumulated to find the radius of the circle. Figure 3 shows the final results of head detection using the HCGT technique over the GOTPD dataset.  
Figure 2: Results obtained after background subtraction using the KDE technique over (**a**) PCDS dataset and (**b**) GOTPD dataset.  
For the detection of shoulders, the joint HOG symmetry-based detection method is used. This type of HOG detection method uses two descriptors of the same size which use the symmetry and continuity of shoulder contours to get higher discrimination and greater detection accuracy. \(d_{i}\) and \(d_{j}\) are the two descriptors, the sample \(p\) joint HOG features can be calculated as [46];  
\[HOG_{d_{i}d_{j}}(p) \tag{4}\]  
The pixel position on \(x\) and \(y\) has a depth value \(l\), gradient magnitude \(g_{m}\) and the direction of the gradient is \(\theta\). We extracted a 1D center gradient operator [\(-1\), 0]. The horizontal gradient and the vertical gradient are calculated as [46];  
\[hg_{x}(x,y)=l(x+1,y)-l(x-1,y) \tag{5}\]  
\[hg_{y}(x,y)=l(x,y+1)-l(x,y-1) \tag{6}\]  
whereas, the pixel gradients located at position (\(x\),\(y\)) are calculated as [46];  
\[hg(x,y)=\sqrt{hg_{x}(x,y)^{2}+hg_{y}(x,y)^{2}} \tag{7}\]  
\[\theta(x,y)=tan^{-1}\frac{hg_{x}(x,y)}{hg_{y}(x,y)} \tag{8}\]  
Thus, each cell of 4 \(\times\) 4 pixels their gradient magnitude according to their gradient direction are calculated and accumulated in bin direction. A histogram of the gradient is obtained. The directional range is from 0-180\({}^{\circ}\) for the joint HOG features of the shoulders, with 5 bin directions. The joint HOG features for the shoulders are then expressed as [46];  
\[H_{d_{i}d_{j}}=\left\{H_{d_{i}},H_{d_{j}}\right\}=v_{1},v_{2},\ldots,v_{L+1} \tag{9}\]  
Finally, these HOG features are normalized to get the joint HOG features of different blocks. Figure 4 shows the results obtained for shoulder detection over the GOTPD dataset.  
Figure 4: Results obtained for shoulder detection using joint the HOG symmetry technique over the GOTPD dataset.  
Figure 3: Final results of head detection using the HCGT technique over the GOTPD dataset.