## Vehicle Detection
### The Construction of Faster RCNN  
The CNN layer is mainly composed of the convolution layer, the pooling layer, and the ReLU layer. The convolutional layer uses specific models to extract features from the target image. Then, the target image is sorted, identified, and predicted by these extracted features. It assumes that the size of the input image is \(M\times N\), the size of the filter kernel is \(K\times K\), the stride is \(S\), and the number of padding pixels is \(P\). Then, the method for calculating the size of the feature map of the convolutional layer output is as follows:  
\[O=\left(I-K+2P\right)/S+1 \tag{1}\]  
In this paper, the parameters of the convolutional layer are defined as: kernel_size = 3, pad = 1. Then the original image becomes \((M+2)\times(N+2)\). The convolution operation is applied with the filter kernel size of \(3\times 3\) and the output size will be \(M\times N\). This method ensures that the convolutional layer in the CNN structure does not change the sizes of the input and output matrices. Pooling layer is usually connected after the convolutional layer to aggregate the features and reduce computational complexity by reducing dimensions. First, the proposal feature maps must go through the full connect layer and softmax layer to calculate the classification proposals and output the detected probability vector _cls_prob_. Next, the position offset _bbox_pred_ of each proposal is obtained by bounding box regression, which is used to regress a more accurate object detection boundary. It assumes that the input image is size \(M\times N\), the filter kernel is size \(K\times K\), the stride is \(S\), and the padding is \(P\). Then, the method for calculating the size of the feature map of the pooling layer output is as follows:  
\[O=\left(I-K\right)/S+1 \tag{2}\]  
In this paper, the parameters of the pooling layer are defined as: kernel size = 2 and stride = 2. A matrix of size \(M\times N\) becomes \((M/2)\times(N/2)\) after the pooling layer operation.  
The RPN network is composed of two structures. One part classifies anchors using the softmax classifier. After the classification, the foreground (the object of detection) and the background can be obtained. Another part is used to calculate the bounding box regression offset of the anchors, which can achieve more accurate proposals. The proposal layer, integrated with foreground anchors and bounding box regression offsets, is used to obtain the boundary candidate boxes for vehicle target. Certain unsuitable proposals are excluded. Then the RPN achieves the target localization by using the proposal layer.  
Figure 1: Basic structure of Faster RCNN.  
The anchors are rectangles generated by a group of RPN. The four values \((x1,y1,x2,y2)\) of each row in the matrix represent the coordinates of the top left corner and the bottom right corner of the rectangular frame.  
There are nine rectangular frames in the matrix with different ratios of length to width. Therefore, anchors introduce a multi scales method for target detection. These nine anchors traverse CNN and obtain feature maps after calculation. Each point uses these nine anchors as the initial detection frame, but the results obtained are inaccurate.  
The bounding box regression image example is shown in Figure 2. The correct Ground Truth (\(GT\)) data is shown by the external thick boundary, and the extracted foreground anchors are shown by the internal thin boundary. In this process, the thin boundary detection range should be adjusted slightly so that the identified foreground anchors are closer to \(GT\). Generally, the window is represented by four-dimensional vectors \((x,y,w,h)\), which represent the coordinate position, width and height of the central point of the window, respectively. Assume boundary \(A\) represents the original foreground anchors. This process is to find a mapping so that boundary \(A\) can be mapped to a regression window \(GT^{\prime}\) that is closer to the actual window \(GT\).