# 3-D People Counting with a Stereo Camera on GPU Embedded Board
## 2 Proposed Method
### View Projection  
Moving objects are projected onto the top view using depth maps and camera parameters. What is required for the view projection is the rotation and translation matrix of the camera relative to the ground. Before calculating the matrices, the world coordinates corresponding to the image coordinates that correspond to the actual ground are required. The side view is characterized by the fact that it contains a lot of ground as it is a viewpoint in a diagonal direction. When the image is divided in half in the horizontal direction, the bottom area contains more ground than the top area. Therefore, the center of the ground in the bottom area is defined as the origin of the world coordinate system. Then, the camera coordinates are converted into the camera coordinates through Equation (4):  
\[ \begin{split} Z_{cam}=\frac{b\cdot f_{x}}{d}\\ X_{cam}=Z_{cam}\frac{(j-cx)}{f_{x}}\\ Y_{cam}=Z_{cam}\frac{(i-cy)}{f_{y}}\end{split}  \tag{4}\]  
where \(X_{cam}\), \(Y_{cam}\), and \(Z_{cam}\) denote the \(x\)-axis, \(y\)-axis, and \(z\)-axis of the camera coordinates, respectively. \(i\) and \(j\) are the image coordinates, \(b\) is the distance between the cameras, \(f_{x}\) is the focal length, \(cx\) and \(cy\) are the camera principal points, and \(d\) is the disparity. Fifty points excluding the origin were randomly selected from the ground, and the camera coordinates were acquired through Equation (4) for each point. Since the origin and 50 points were on the same ground, the Z-axis value in the world coordinate  
Figure 8: Background subtraction result: (**a**) depth map, and (**b**) background subtraction result. was zero. The X-axis and Y-axis values of the world coordinates for 50 points are expressed as the distance between the camera coordinates of the origin and the camera coordinates of the 50 points as shown in Equation (5):  
\[Z_{world}=0 \tag{5}\] \[X_{world}=X_{cam}-X^{\prime}{}_{cam}\] \[Y_{world}=Y_{cam}-Y^{\prime}{}_{cam}\]  
where \(X_{world}\), \(Y_{world}\), and \(Z_{world}\) represent the \(X\), \(Y\), and \(Z\) values of the world coordinate, respectively. \(X^{\prime}{}_{cam}\) and \(Y^{\prime}{}_{cam}\) indicates the camera coordinate value of the origin. The camera rotation matrix and the translation matrix for the ground were obtained using the image coordinates and world coordinates for the 50 points. The reason for extracting the 50 points randomly is that an incorrect matrix value can be obtained when an inaccurate depth value is referred to in a depth image. It is possible to obtain a matrix with high reliability by referring to a large number of points, but we could obtain good results by referring to about 50 through experiments. After obtaining the camera rotation matrix and the translation matrix, the world coordinate value is obtained through Equation (6) for the foreground obtained in the background subtraction:  
\[P_{w}=R^{T}(C-T) \tag{6}\]  
where \(R\) and \(T\) are the camera rotation matrix and translation matrix, respectively, \(C\) is the camera coordinate of each point, and \(P_{w}\) is the world coordinate value. The world coordinate value of the foreground is for the previously set origin. These values were used to construct a height map. The \(x\)-axis value of the height map was created using the world coordinate \(X\) value of the foreground. In the same way, the \(y\)-axis value of the height map was created using the world coordinate \(Y\) value of the foreground. The value of each pixel in the height map was the world coordinate \(Z\) value of the foreground. The \(Z\)-axis value refers to the height of the ground since the origin was set to the ground. Figure 9b shows the generation of the height map using the color and depth images. The more reddish the color in the height map, the higher the height. The height map is noisy due to errors in the depth value. In addition, since only the height of the object is expressed, additional indicators are needed to detect a person.