# A Rotation Target Detection Network Based on Multi-Kernel Interaction and Hierarchical Expansion
## 3 Methodology
### Midpoint Offset Loss Function  
For rotated object detection, the rotation angles of bounding boxes are typically divided into several discrete intervals; however, this discretization introduces quantization errors. In addition, regression of the rotation angles is necessary in order to handle periodic problems, which increases the difficulty of training. If a complete parameter regression method is adopted, then mismatch between the physical characteristics of angle regression and the optimization mechanism of neural networks occurs, leading to unstable training and high computational overhead. Some existing anchor-free methods directly predict the center points and sizes of objects without presetting anchor boxes; however, these are prone to confusion about the center points of objects, and their detection effects are limited for multi-scale objects. In order to design a bounding box representation scheme that is easy to train and can achieve accurate regression for objects of different scales, we first preset horizontal reference boxes of different scales through anchor boxes. This approach can inherit the multi-scale priors of horizontal anchor boxes, assist the network in learning the common direction patterns of objects, and reduce the ambiguity of anchor-free methods. Then, by introducing the offset of the midpoints at the top and right sides, direction information is added to the horizontal boxes to improve positioning accuracy. This method only needs to add two additional offset parameters to describe oriented objects on the basis of traditional bounding boxes, without the need to introduce complex angle parameters. Finally, a loss function between the offsets is designed to learn the parameters. Specifically:  
Anchor Box Initialization: Across all hierarchical feature maps, we instantiate three horizontally-oriented anchor boxes per spatial position, configured with aspect ratios of 1:2, 1:1, 2:1. Each anchor box \(a\) is represented by a four-dimensional vector \(a=(a_{x},a_{y},a_{w},a_{h})\)where \((a_{x},a_{y})\) is the central coordinate of the anchor box and where \(a_{w}\) and \(a_{h}\) denote the width and height of the anchor box, respectively. Offset Prediction: One of the two sibling \(1\times 1\) convolutional layers is the regression branch, which outputs the offset \(\delta=(\delta_{x},\delta_{y},\delta_{w},\delta_{h},\delta_{a},\delta_{g})\) of the candidate box relative to the anchor box. We can obtain the oriented candidate box by decoding the regression output. The decoding process is described as follows:  
\[\Delta a=\delta_{a}\cdot w,\quad\Delta\beta=\delta_{g}\cdot h, \tag{11}\] \[w=a_{w}\cdot e^{b_{w}},\quad h=a_{h}\cdot e^{b_{h}},\] \[x=\delta_{x}\cdot a_{w}+a_{x},\quad y=\delta_{y}\cdot a_{h}+a_{ y},\]  
among which \((x,y)\) represents the central coordinates of the predicted candidate box and \(w,h\) represents the width and height of the bounding rectangle of the predicted oriented candidate box. As shown in Figure 3, \(\Delta a\) and \(\Delta\beta\) are the offsets relative to the midpoints of the upper and right sides of the bounding rectangle, respectively. Decoding and Loss Calculation: We generate the oriented candidate box \(O\) based on \((x,y,w,h,\Delta\alpha,\Delta\beta)\). Then, the coordinate sets of the four vertices of each candidate box are obtained as \(V=(A,B,C,D)\). The coordinates of the four vertices can be expressed as follows:  
\[A=(x+\Delta\alpha,y-h/2), \tag{12}\] \[B=(x+w/2,y+\Delta\beta),\] \[C=(x-\Delta\alpha,y+h/2),\] \[D=(x-w/2,y-\Delta\beta).\]  
Leveraging this encoding scheme, we parameterize each oriented bounding box through joint prediction of its enclosing rectangle parameters \((x,y,w,h)\) and midpoint offset deltas \((\Delta\alpha,\Delta\beta)\) to enable precise regression. Positive and negative sample definitions are specified as follows. First, a binary label \(p^{*}\in\{0,1\}\) is assigned to each anchor box, where 0 and 1 denote negative and positive samples, respectively.