# Addressing the Gaps of IoU Loss in 3D Object Detection with IIoU
## 4 Proposed IIoU Loss  
Let \((x_{g},y_{g},z_{g},l_{g},w_{g},h_{g},\theta_{g})\) and \((x_{p},y_{p},z_{p},l_{p},w_{p},h_{p},\theta_{p})\) denote 3D ground-truth regression vector and 3D prediction branch vector. We isolated a selected ground truth box as \((x_{1},y_{1},z_{1},l_{1},w_{1},h_{1},\theta_{1})\) and selected prediction box as \((x_{2},y_{2},z_{2},l_{2},w_{2},h_{2},\theta_{2})\). Following the common settings [30; 43], we set \(\theta_{11}=\text{sin}\theta_{1}\text{cos}\theta_{2}\) and \(\theta_{12}=\text{cos}\theta_{1}\text{sin}\theta_{2}\). \(\theta_{11}\) and \(\theta_{12}\) were clamped to avoid infinity values. Our proposed IIoU loss has two portions: IoU loss and center loss. Following the initial settings, IoU values are calculated as follows:  
\[I=F(x_{1},x_{2},l_{1},l_{2})+F(y_{1},y_{2},w_{1},w_{2})+F(z_{1},z_{2},h_{1},h_ {2})\]  
whereas,  
\[F(a,a^{\prime},b,b^{\prime})=min(\frac{a+b}{2},\frac{a^{\prime}+b^{\prime}}{2 })-max(\frac{a-b}{2},\frac{a^{\prime}-b^{\prime}}{2}) \tag{10}\]  
The min and max functionality estimates the intersection area between the two boxes in 3D space, and the overall IoU of two 3D boxes are calculated in (11). \[U=l_{1}*w_{1}*h_{1}+l_{2}*w_{2}*h_{2}-I\]  
\[\text{IoU}=I/U \tag{11}\]  
The diagonal length of the minimum convex rectangle enclosing the ground truth and prediction boxes is calculated as follows:  
\[Diagonal=F^{\prime}(x_{1},x_{2},l_{1},l_{2})+F^{\prime}(y_{1},y_{2},w_{1},w_ {2})+F^{\prime}(z_{1},z_{2},h_{1},h_{2})+F^{\prime}(\theta_{1},\theta_{2},K,k) \tag{12}\]  
\[F^{\prime}(a,a^{\prime},b,b^{\prime})=(max(\frac{a-b}{2},\frac{a^{\prime}-b^{ \prime}}{2})-min(\frac{a+b}{2},\frac{a^{\prime}+b^{\prime}}{2})) \tag{13}\]  
The K value is a hyperparameter since we consider orientation as an additional dimension in distance loss estimation. Estimating intersection area and diagonal distance are adapted from [27] but modified to include all the dimensions for 3D space. Our proposed loss IIoU estimates the Euclidean distance between x, y, and z centers individually to estimate the center loss. The center coordinate of each axis, along with the minimum and maximum edges, are utilized as follows,  
\[d^{2}(CD_{x})=(x_{1}^{cc}-x_{2}^{cc})^{2}+(y_{1}^{min}-y_{2}^{min})^{2}+(z_{1} ^{min}-z_{2}^{min})^{2}+(\theta_{1}^{min}-\theta_{2}^{min})^{2} \tag{14}\]  
In the above Equation (14), the Euclidean distance between x centers is calculated. Similarly, we can estimate the Euclidean distance for y and z centers (line 10 in Algorithm 1). Once the center distance is calculated, the diagonal length is a denominator to minimize the distance between two boxes. The IIoU can be obtained at line 12 in Algorithm 1. This approach has a few advantages when compared to traditional IoU losses. Rotation as an additional dimensional parameter simplifies loss calculation when the boxes are not aligned/rotated. For instance, when the boxes are a little tilted, and two axes coincide, Euclidean distance estimation of rotation and other third axis aids in effective loss estimation. Secondly, when the boxes have different orientations but have the same centers, existing losses fail as they are heavily dependent on the centers. Previous studies [26] show that two boxes with the same centers can still have different dimensions. The same observation can be made regarding aspect ratios. All the bounding box parameters in our proposed loss equation are completely differentiable and can be trained on GPU with gradient-based back-propagation. Our Algorithm 1 presents sequential steps carried out in loss estimation. ```
0:\(B^{S}=(x_{g},y_{g},z_{g},l_{g},w_{g},h_{g},\theta_{g})\), \(B^{p}=(x_{p},y_{p},z_{p},l_{p},w_{p},h_{p},\theta_{p})\).