# Binocular Vision-Based Pole-Shaped Obstacle Detection and Ranging Study
## 2 Methods
### MKS Loss Function  
Object detection and recognition classification are key research areas in computer vision, and the loss function plays an important role in determining detection accuracy. The loss function is used to evaluate the difference between the model's prediction result and the actual target. The smaller the loss function value, the closer the prediction result is to the actual target. The loss function of YOLOv5 consists of three main components: rectangular box loss (box loss), confidence loss (obj loss), and classification loss (cls loss). Therefore, the total loss function of the YOLOv5 algorithm is defined as follows:  
\[\text{Total loss = A \times obj loss + B \times cls loss + C \times box loss} \tag{1}\]  
where, A, B, and C are the weight values of the three loss functions and A = 1, B = 0.5, and C = 0.1. In the current study, YOLOv5 utilizes the CIoU loss function [18]. However, this loss function only considers the aggregation of the bounding box regression metrics and does not account for the mismatch between the required true and predicted frames. As a result, it leads to slow convergence and low efficiency. Therefore, the SloU loss function [19] is used instead of the original loss function. However, there are some problems with the SloU loss function, such as category imbalance in rod obstacles, the overlapping of multiple  
Figure 1: Overall workflow diagram. prediction frames, and the issue of optimal matching. Therefore, based on the SIoU loss function, the Monge-Kantorovich (MK) [20] function is introduced to optimize the IoU loss function. Specifically, the MK algorithm considers two sets of points as input values. In other words, the predicted bounding box and the true bounding box are treated as sets of points. Then, the distance matrix between these points is computed, where each entry in the matrix represents the distance between the predicted bounding box and the true bounding box. Finally, the Sinkhorn-Knopp algorithm [21] is used to find the best match between the predicted and real bounding boxes, minimizing the total negative IoU loss. In addition, the \(MK\) function can regularize the model to prevent overfitting. To better understand the \(MK\) function, it is defined as follows. The mathematical definition of the Monge problem [22] is: Given two metric spaces \(X\) and \(Y\) and two probability measures \(\mu\in P(X)\), \(\
u\in P(Y)\), loss function c: \(X\times Y\)\(\rightarrow\)\(R\cup\{+\infty\}\):  
\[(MP):=\inf\biggl{\{}\int_{X}\mathrm{c}(x,\mathrm{T}(x))\mathrm{d}\mu(x)\text{: }\mathrm{T}_{\mu\mu=\
u}\biggr{\}} \tag{2}\]  
where c (\(x\), \(\mathrm{T}(x)\)) denotes the loss of \(x\) to \(\mathrm{T}(x)\), \(\mathrm{T}_{\mu\mu=\
u}\) denotes the mapping between \(\mu\) and \(\
u\), and \(\mathrm{T}\) extrapolates the probability measure \(\mu\) to \(\
u\). [PERSON] generalizes the transmission mapping to the joint probability distribution, which has:  
\[\prod(\mu,\
u)=\left\{\gamma\in P(X\times Y)|\pi_{X\pi\gamma}=\mu,\pi_{Y\pi \gamma}=\
u\right\} \tag{3}\]  
The Kantorovich problem [23] is mathematically defined as two probability measures \(\mu\in P(X)\) and \(\
u\in P(Y)\) and a cost function c:\(X\times Y\)\(\rightarrow\)\(R\cup\{+\infty\}\) for two metric spaces \(X\), \(Y\):  
\[(KP):=\inf\biggl{\{}\int_{X\times Y}\mathrm{c}(x,y)\mathrm{d}\gamma(x,y)| \gamma\in\prod(\mu,\
u)\biggr{\}} \tag{4}\]  
In [PERSON]'s problem, only one type of mapping can be targeted, either one-to-one or many-to-one. However, the [PERSON] problem can be solved by simplifying the problem in a one-to-many manner. The SIoU loss function is introduced to redefine the existing loss functions for the current problem, which include angle loss, distance loss, shape loss, and IoU loss. The IoU loss is the most commonly used loss function for target detection. It represents the intersection over the union ratio of the true and predicted frames. However, while the IoU metric is used for computation, negative IoU is used for optimization during training. Negative IoU is defined as follows.