## 4 Machine Learning for Object Detection
### YOLO Object Detection and Localization  
Object detection is a task in computer vision that involves identifying the presence and type of one or more objects in a given image. There are various types of object detection algorithms [19; 20; 21; 22; 23; 24; 25], and YOLO is one of them with its fastest detection and localization mechanisms. [PERSON] et al. [26] reported the preference of YOLO over the other detection algorithms that runs on CNN. The key features underpinning YOLO as the fastest detection means are applying a single neural network on the entire image and  
Figure 3: Quadcopter equipped with on-board components.  
considering detected object localization as a regression problem. The architecture of this neural network is called Darknet: a type of CNN. It has 24 convolutional layers working as feature extractors and 2 dense layers for doing the predictions. A detailed discussion on the neural network and its architecture is given by [PERSON] et al. [27]. There is a configuration file with a given architecture. This file contains information about:  
* layers and activations of the architecture
* anchor boxes
* number of classes
* learning rates
* optimization techniques
* input size
* probability score threshold
* batch size  
Each configuration file has corresponding pre-trained weights. For training, YOLO requires two files: a file with list of names of objects and a file with a list of training images that contain desired objects with their corresponding labels. The labels are relative centers and dimensions of objects in the image. The configuration file can be modified as per the need of a user. For instance, increasing the batch value improves and speeds up the training but at the cost of demanding more memory. Two of the most important parameters in the configuration file that need to be checked are classes and final layer filters. The values of these parameters should match with the total number of objects in the training.  
Once the training is over, the configuration and corresponding weight files are integrated with YOLO Darknet ROS module for object detection and localization during autonomous navigation of UAVs. Along with the detection of each object, there is a bounding box, which is characterized by the following parameters.  
* confidence score that the object is detected
* center of the bounding box (\(U_{c}\),\(V_{c}\))
* dimension of the bounding box (\(w\), \(h\))  
where \(U\) and \(V\) are coordinate axes of an image frame in which \(U\) increases from left to right and \(V\) increases from top to bottom. Both the center and dimensions of the box are normalized to fall between 0 and 1. Based on these parameters, the sides of the bounding box can be calculated as:  
\[U_{min}=U_{c}-\frac{w}{2}\qquad\text{and}\qquad U_{max}=U_{c}+\frac{w}{2} \tag{1}\]  
and  
\[V_{min}=V_{c}-\frac{h}{2}\qquad\text{and}\qquad V_{max}=V_{c}+\frac{h}{2} \tag{2}\]  
where \(U_{min}\) and \(U_{max}\) are the locations of left and right sides of the bounding box along the U-axis. Similarly, \(V_{min}\) and \(V_{max}\) are the locations of upper and lower sides of the bounding box along the V-axis. The coordinate transformation from the image frame to camera frame follows the procedure shown in [28]. Since the path planner was written as the ROS node that follows a reference frame FLU (Forward (x), left (y), and upward (z)), coordinate transformation from camera frame to ROS frame (FLU) was done. Moreover, PX4 uses FRD (Forward (x), right (y), and Down (z)). The ROS package MAVROS handles coordinate frame transformation from ROS frame to PX4 frame.