# Addressing the Gaps of IoU Loss in 3D Object Detection with IIoU
## 3 Analysis on 3D IoU Losses  
Given a ground truth (GT) box G = {x\({}_{\rm{g}}\), y\({}_{\rm{g}}\), z\({}_{\rm{g}}\), w\({}_{\rm{g}}\), h\({}_{\rm{g}}\), l\({}_{\rm{g}}\), \(\theta\) g} and a prediction (Pred) box P = {x\({}_{\rm{p}}\), y\({}_{\rm{p}}\), z\({}_{\rm{p}}\), w\({}_{\rm{p}}\), h\({}_{\rm{p}}\), l\({}_{\rm{p}}\), \(\theta\) p}, whereas, x, y, and z represent the center coordinates along the x, y, and z-axis and l, w and h indicate the length, width and height along their respective axes and \(\theta\) denotes the orientation of an object. The IoU between the boxes [69] are calculated as follows,  
\[\text{IoU}=\frac{I(P,G)}{U(P,G)}=\frac{|P\cap G|}{|P|+|G|-|P\cap G|} \tag{1}\]  
\[L_{IoU}=1-\text{IoU(P,G)} \tag{2}\]  
However, the above IoU loss works well for axis-aligned bounding boxes. However, loss estimation for rotated bounding boxes is more complex cause the boxes can overlap and intersect differently. To address this problem, skewIoU [67] was proposed as follows,  
\[\text{skewIoU}=\frac{A_{I}*h_{I}}{A_{G}*h_{G}+A_{P}*h_{P}-A_{I}*h_{I}} \tag{3}\]  
In the above Equation (3), I represent the overlap /intersection area. During the loss estimation, boxes with intersection area are sorted in anticlockwise order, and skewIoU estimates the overall IoU. However, this method also depends on intersection areas like Equation (1), which results in a high loss value of 1 in the event of two boxes located far from each other without any overlap. Sorting the vertices in an anticlockwise direction adds computation time in loss estimation. To address the shortcomings of IoU loss, GIoU [27] was proposed as follows,  
\[L_{GIoU}=1-\text{IoU}+\frac{|CA-U(P,G)|}{|CA|} \tag{4}\]  
As seen in Equation (4), \(L_{GIoU}\) considers a small convex rectangle enclosing both boxes. This loss technique addresses the edge cases when the boxes are away from each other and have zero intersection area. However, when the boxes are inclusive of each other, the IoU term in Equation (4) becomes 1, and convergence slows down, affecting the gradient estimation. A new variation of GIoU called smooth GIoU was proposed to ensure stable convergence in GIoU loss. Ref. [28] introduced a smoothness parameter if GIoU loss reaches a specific threshold value (\(\delta\)) as shown in Equation (5). \[\text{Smooth(GIoU)}= \begin{cases}GloU_{L1}(GloU),&GloU<\delta\\ GloU_{L2}(GloU),&\text{otherwise}\end{cases}  \tag{5}\]  
However, Equation (3) degrades to IoU in case of inclusion and cannot overcome the aspect ratio difference between the boxes. For instance, in Figure 1, the boxes are of different orientations and sizes, but their overlapping and convex areas remain constant. The loss estimation for rotated bounding boxes is more complex cause the boxes can overlap and intersect in different ways [63; 67]. To address the problem of overlap and aspect ratio similarity, DIoU and CIoU losses were proposed. \[L_{DIoU}=1-\text{IoU}+\frac{d^{2}(P,G)}{c^{2}} \tag{6}\]  
\[L_{CIoU}=1-\text{IoU}+\frac{d^{2}(P,G)}{c^{2}}+av \tag{7}\]  
\[v=\frac{4}{pi*pi}(arctan\frac{w^{G}}{h^{G}}-arctan\frac{w^{P}}{h^{P}})^{2} \tag{8}\]  
Equation (6) regresses the centers of the bounding boxes in addition to the overlap area. In the minimum rectangle containing the prediction and ground truth boxes, C represents the diagonal distance from the center of each box. This helps in convergence when the boxes are inclusive but with different centers and in cases where the boxes do not overlap. However, \(L_{DIoU}\) is scale invariant. To address the scale invariance problem, \(L_{CIoU}\) added a new term called \(\alpha\) to address the gap in aspect ratio between the boxes. However, as seen in Equation (8), \(\alpha\) considers only two aspect ratios, such as w and h. For 3D boxes, a third aspect ratio l exists, which is not utilized in \(L_{CIoU}\). To address this gap in aspect ratio and consider all geometric sides, authors of this research [63] proposed 3D EIoU loss.