# Cell-Based Target Localization and Tracking with an Active Camera
## 3 Methodology
### Target Localization on an Image  
This research employs YOLOv4 to complete the detection and recognition of ship targets in the image. [PERSON]'s team proposed YOLOv4 in 2020. This algorithm is based on the YOLO series [34; 35; 36; 37] and can accurately and rapidly detect and identify targets in images. On the Tesla V100, the YOLOv4 algorithm detects objects in real time at a rate of 65 fps and with an accuracy of 43.5% AP.  
The prediction method of the YOLO series algorithm is shown in Figure 3. The recognition result of YOLOv4 is shown in Figure 4. The neural network predicts five bounding boxes on each unit of the feature map, and each bounding box indicates five values, which are \(t_{x},t_{y},t_{w},t_{h},t_{o}\). The first four values are coordinates and \(b_{o}\) is the confidence level. The length and width of the bounding box corresponding to the cell are \((p_{w},p_{h})\), respectively. The distance between the cell and the upper left corner of the image is \((c_{x},c_{y})\). Then, the predicted value is  
\[b_{x}=\sigma(t_{x})+c_{x} \tag{1}\]  
\[b_{y}=\sigma(t_{y})+c_{y} \tag{2}\]  
\[b_{w}=p_{w}e^{t_{w}} \tag{3}\]  
\[b_{h}=p_{h}e^{t_{h}} \tag{4}\]  
\[\text{Pr}(\text{object})*\text{IOU}(b,\text{object})= s(t_{o}) \tag{5}\]  
In the text, (Target: \((b_{x},b_{y})\)) is used to represent the target in the image; \"Jeep\" and \"cross\" are the target types; and \((b_{x},b_{y})\) are the coordinates of the center point of the target bounding box.  
Figure 4: Target detection with YOLOv4.  
Figure 3: Bounding box prediction of the target.  
We detected the coordinates of the target in the image and the coordinates of all cell vertices with the YOLOv4 algorithm, and then compared the pixel distances from the image's principal point to all vertices in the image. The distance formula is:  
\[S=\sqrt{\left(X_{\text{O}}-X_{1}\right)^{2}+\left(Y_{\text{O}}-Y_{1}\right)^{2}} \tag{6}\]  
We picked out the four vertices closest to the center of the image and considered these four vertices to be the four vertices of a cell. The world coordinates of the principal point of the image in the scene can be calculated with the PTH model. Because the world coordinates of the vertices of each cell are manually calibrated when the scene cell is divided, it is easy to calculate in which scene cell the principal point of the image is located. Finally, the proposed matching method matches the vertices of the image cell with the vertices of the scene cell. For different channels (horizontal or vertical), different matching methods are adopted.  
For the horizontal channel, the method used mainly includes two steps. First, we calculated the distance between the vertices of the cell and the vertex of the lower left corner of the image to identify the vertices A1 and A3. Then, we calculated the abscissa of the remaining two vertices. The vertices A2 and A4 can be identified as well. The specific identification method is shown in Figure 5.  
For the vertical channel, the method adopted is shown in Figure 6:  
When the principal point of the camera is at the starting point, it can be directly determined that the target is in the first cell After the camera moves for the first time, the cell recognition method shown in Figure 6 can be adopted. Figure 6 shows the method to distinguish the cell's vertices in the vertical channel. Under different shooting angles, the attitude of the cell is different, but its direction is generally as shown in Figure 6. The abscissa value of vertex A2 is the largest, the abscissa value of vertex A4 is the smallest, the ordinate of vertex A1 is the largest, and the ordinate of vertex A3 is the smallest. The four vertices can be distinguished in this way.  
Figure 5: Recognition method of the cell vertex in the horizontal channel.  
Figure 6: Recognition method of the apex of the vertical channel.