## 3 Materials and Methods
### Main Algorithms Used  
#### 3.2.1 YOLOv2--Object Detection  
One of the important networks used in our proposed system is YOLOv2 and TinyYolo for object detection. While the gripper starts rotating to detect a barcode placed on an object, a single-stage real-time object detection pipeline, You Only Look Once (YOLO), is running. The object detection process, depicted in Figure 2, includes locating and classifying certain objects on an image. The input image is first divided into an \(S\times S\) grid of cells, each of which is responsible for detecting objects falling in the grid, and each grid returns the bounding box information and the probability belonging to a certain classification.  
Each bounding box (\(B\)) has five components: (\(x\), \(y\), \(w\), \(h\), confidence). The \(x\), \(y\) coordinates represent the center of the box relative to the bounds of the grid cell, and \(w\), \(h\) are predicted, relative to the image size. These coordinates are then normalized to become between 0 and 1. The confidence prediction, shown in Equation (1), is represented by the IOU between the prediction box and any ground truth boxes. These confidence scores reflect how confident the model is that the box contains an object and also how accurate it thinks the box is that it predicts.  
\[Pr(Object)*IOU(pred,truth) \tag{1}\]  
where \(Pr(Object)\) represents the probability that the bounding box contains the object. Finally, the predictions are encoded as an \(S\times S\times(B\times 5+C)\) tensor, where the image is divided into an \(S\times S\) grid and for each grid, the cell predicts \(B\) bounding boxes, the confidence for those boxes, and the \(C\) class probabilities.  
The loss function, described in Equation (2), is composed of classification loss, localization loss and confidence loss. Unlike other algorithms, this approach learns a generalizable representation of the objects and makes accurate predictions with a single neural evaluation. The algorithm thresholds the predictions and performs non-maximum suppression to remove duplicates and outputs bounding boxes that define the sections with objects [18].  
\[\begin{split}\lambda_{coord}&\sum_{i=0}^{S^{2}}\sum _{j=0}^{B}1_{ij}^{\text{obj}}((x_{i}-\hat{x}_{i})^{2}+(y_{i}-y_{i})^{2})+ \lambda_{coord}\sum_{i=0}^{S^{2}}\sum_{j=0}^{B}1_{ij}^{\text{obj}}(\sqrt{w_{i }}-\sqrt{\hat{w}_{i}})^{2}+(\sqrt{h_{i}}-\sqrt{h_{i}})^{2})+\\ &\sum_{i=0}^{S^{2}}\sum_{j=0}^{B}1_{ij}^{\text{obj}}(C_{i}-\hat{ C}_{i})^{2}+\lambda_{noboj}\sum_{i=0}^{S^{2}}\sum_{j=0}^{B}1_{ij}^{\text{ nobj}}(C_{i}-\hat{C}_{i})^{2}+\sum_{i=0}^{S^{2}}1_{i}^{\text{obj}}\sum_{c\in classes }(p_{i}(c)-\hat{p}_{i}(c))^{2}\end{split} \tag{2}\]  
In our proposed system, we use YOLOv2 along with TinyYOLO feature extraction in the object detection pipeline, due to its advantages compared to other state-of-the-art detection algorithms. The YOLO algorithm has the advantage of being capable of  
Figure 2: Yolo pipeline.  
recognizing and locating up to 49 objects in a single image. In terms of performance and speed, the YOLO algorithm is able to accurately detect objects in real time, making it suitable for our use case.