# Design and Control of an Ultra-Low-Cost Logistic Delivery Fixed-Wing UAV
## 3 Overview of Image Recognition Technology
### Target Identification Applications
#### 3.3.3 Target Coordinate Information Solution  
To localize targets detected in video streams, it is essential to obtain parameters, such as latitude, longitude, altitude, and attitude angles, at the time of the UAV capture. These parameters can be acquired from the UAV's telemetry data. Utilizing the UAV's attitude angles, actual ground coordinates are transformed via rotation and translation into a local coordinate system with the UAV as the reference point, such as Figure 27.  
Through prior work, we can accurately identify and frame targets within the original image, leading to the critical next step for computing target coordinate information [71]. Target coordinate computation has broad applications in computer vision and image processing, allowing for the precise localization and tracking of targets in the three-dimensional world. For instance, in autonomous driving, robotic navigation, and UAV flights, target coordinate computation aids in determining the position and orientation of vehicles, robots, or UAVs on the ground or in the air, facilitating flights and path planning. Accurate target  
Figure 27: Target-relative coordinate system’s transformation model.  
Figure 26: OpenCV’s object-detection-process diagram.  
coordinates relative to the UAV are necessary for simulating deliveries, such as dropping a 500 mL water bottle as a payload.  
With [PERSON]'s method being adopted in this study [72] during the camera calibration, capturing chessboard patterns at different angles and distances helps to obtain the camera's internal parameters and distortion coefficients. Selecting the best set of distortion coefficients reduces calibration errors for distortion correction. Having obtained the camera's intrinsic and extrinsic parameters--K as the camera's intrinsic matrix and \([R|T]\) as the rotation and translation matrix--precise target identification allows us to determine the target center's pixel coordinates, \((u,\ v)\). The following equations normalize pixel coordinates to planar coordinates, \((x,\ y)\):  
\[x=u/fy=v/f \tag{20}\]  
The inverse matrix, \(K^{-1}\), of the normalized planar coordinates, \((x,y)\), and the inverse matrix of the camera's internal parameter matrix can be used to convert the normalized coordinates into coordinates in the camera's coordinate system, \((x\_c,y\_c,z\_c,1)\) as follows:  
\[[x\_c,y\_c,1]^{\mathrm{T}}=K^{-1}\times\Big{[}x,y,1]^{\mathrm{T}} \tag{21}\]  
The coordinates in the camera's coordinate system, \((x\_c,y\_c,z\_c,1)\), are then rotated by the rotation matrix (R) and translation vector (T) from the out-of-camera parameters to coordinates \((x,y,z)\) in the real-world coordinate system as follows:  
\[[X,Y,Z,1]^{T}=[R\ |\ T]^{-1}\times[x\_c,y\_c,z\_c,1]^{T} \tag{22}\]  
Using the above process, the image coordinates, \((u,v)\), can be converted into real-world coordinates, \((X,\ Y,\ Z)\), which, in this study, also need to be converted into coordinates in WGS84. In this study, let A be the radius of the unit circle and E be the first eccentricity of the Earth. Let the equatorial radius of the reference ellipsoidal sphere be c, the polar radius of the reference ellipsoidal sphere's bed, and let B be the latitude of the UAV, and the formulae are as follows:  
\[\left\{\begin{array}{l}A^{2}=\frac{a^{2}-b^{2}}{a^{2}}\\ N=\frac{a}{\sqrt{1-A^{2}}\text{sin}^{2}B}\end{array}\right. \tag{23}\]  
Finally, the latitudinal and longitudinal information of the target in WGS84 is determined using the following equations:  
\[\left\{\begin{array}{l}L=\arctan\frac{Y}{X}\\ M=\arctan\frac{Z+A\times E^{2}\sin B}{\sqrt{X^{2}+Y^{2}}}\\ H=\frac{\sqrt{X^{2}+Y^{2}}}{\cos B}-A\end{array}\right. \tag{24}\]  
where \(L\) is the longitude of the target, \(M\) is the dimension of the target, and \(H\) is the altitude of the target (0 for ground targets). So far in this study, the coordinate information of the target has been obtained.