# Video-Based Parking Occupancy Detection for Smart Control System
## 2 Materials and Methods
### IOU and Overlapping  
We used the modified detection model to verify the accuracy of the CNRPark + EXT dataset. The parking grid provided in the dataset is presented in Figure 10. The dataset presented in [PERSON] and [PERSON]'s approach for real-time car parking occupancy detection used a CNN to classify parking space status. The CNN model judged whether cars were in parking spaces after assigning bounding boxes to each parking space. However, a real parking grid was used to judge this reasonable;  
Figure 9: Comparison of convolutional blocks among architectures.  
therefore, we applied our method to automatically generate the actual parking gridline, as revealed in Figure 10b. The parking grid automatic generation method was provided in [PERSON]'s study [47], which provided a canny edge and Hough line to detect edges on real parking grids.  
In the parking dataset, we used the center points of bounding boxes, which were predicted using YOLO to create a comparison table by using the methods of [PERSON] [20] and [PERSON] et al. [25]. The model achieved considerable accuracy, but the center point may have misjudged actual parking spaces because of the network surveillance camera's perspective, as shown in Figure 10c. To resolve the problem of misaligned perspectives, we propose a method of YOLO detection and object overlapping identification to improve occupancy detection results and to identify the occupancy status with the voting mechanism. Our judgment method of the overlapping is presented below (see Figure 11).  
This step used YOLO to help find objects from the image, and could quickly determine object locations from the model. The camera angle caused difficulties in understanding if the item had passed the streetlight or parking space, and even determining which objects entered which parking grid was difficult. We used bounding boxes to calculate areas from the YOLO detection model, the area of each parking grid, the overlapping area ratio, and IOU. \(B\) and \(G\) represent two areas of object and parking grids, and \(t\) represents threshold. \(IOU(B,\ G)\) and \(Overlapping(B,\ G)\) are defined as follows:  
\[IOU\ ratio(B,\ G)=B\cap G\div B\cup G \tag{5}\]  
\[Overlapping\ ratio(B,\ G)=B\cap G\div G \tag{6}\]  
where \(B\cap G\) is intersection area and \(B\cup G\) the bounding box and parking space area. IOU calculation revealed parking grids closest to bounding boxes, and the overlapping ratio revealed the location of the largest ratio of bounding boxes. Furthermore, the IOU prevented cars in the front row from occluding with cars in the back. In other words, the IOU could compensate for overlapping limitations. When \(IOU\ ratio(B,\ G)>t\), the car then found the closest parking grid. When \(Overlapping\ ratio(B,\ G)>t\), the model found the parking space containing the bounding box.  
Figure 11: (**a**) Real-time situation of the overlapping area; (**b**) overlapping; and (**c**) IOU.  
Figure 10: Comparison of methods using center points and area. (**a**) Parking lots. (**b**) Green bounding boxes provided by the dataset determine parking-space occupancy. (**c**) Blue bounding boxes are detected using YOLO. (**d**) The overlapping and IOU method is used to determine parking occupancy.  
IOU and overlapping determined the intersection area with percentages that inferred bounding boxes of cars occupying parking spaces. Therefore, we manipulated the camera angle to be set up when intersection area ratios were larger than the threshold of a certain area ratio. Therefore, we could determine objects entering grids. After cars were ensured to have stopped, the parking grids occupied by cars were judged. After obtaining each overlapping area ratio, we extracted the maximum value to enter the voting mechanism. In the voting mechanism, we used the voting concept to check whether a certain number of each five images showed a status that indicated that the space tended to be occupied. Figure 12 displays the schematic diagram.