# A Comprehensive Analysis of Real-Time Car Safety Belt Detection Using the YOLOv7 Algorithm
## 3 Materials and Methods
### Stage 1: Data Collection  
The primary challenge encountered in this research is the lack of availability of a suitable dataset, which is also acknowledged by [PERSON] et al. (2018). To address this issue, we decided to capture live video footage from within a moving car. The decision to record data in a moving vehicle was to obtain real-world data that encompass varying light intensities and blurred images caused by car vibrations. The data collection process was carried out in November and December 2022 (summer period) in Cape Town, South Africa. During this period, a diverse range of clothing types to simulate real-life scenarios was obtained. Some datasets were acquired through crowdsourcing, where we solicited video contributions from social media platforms. Consent was given by all individuals who donated their videos. Additionally, we obtained other datasets by downloading random photos from the internet to augment the diversity of the collected data. The video dataset was then converted to images using the VLC media player program. Table 2 gives figures of the collected dataset, and Figure 5 shows a representative sample of the dataset collected from video images. The sample dataset shows a few scenarios that this study was investigating. Amongst those scenarios, there are blurry images, clear images, high-light-intensity images, images with clothing similar to the safety belt, and images where the pillar loop was occluded. In all instances, the proposed study was expected to discriminate between the buckled and unbuckled status of a safety belt. The collected dataset was augmented using the noise addition and brightness contrast approaches. The benefits of these augmentation approaches were an increase in the number of datasets and the robustness of the model in changing environments inside the vehicle.  
Figure 4: The flow diagram of the proposed study.  
The annotation process was carried out using the labelImg tool, resulting in the generation of a label file in the \".txt\" format. The dataset underwent annotation using the YOLO format, which entailed the application of rectangular bounding boxes. The annotation procedure encompassed the identification of the Region of Interest (ROI) as the pillar loop and the safety belt webbing. In instances where the pillar loop was not perceptible, the corresponding images were designated as unlatched. On the other hand, in cases where the pillar loop was observable, the images were designated as exhibiting buckling. The bounding rectangles were visually represented as annotations and identified in written form as follows: The first number in the line represented the category of the object, represented by an integer, while the subsequent four numbers indicated the coordinates of the bounding boxes. The initial two numerical values denoted the central point of the enclosing rectangle in relation to the X and Y axes, respectively. These values were then divided by the height and width of the image. The final two numerical values denoted the dimensions of the bounding box, with one representing the width and the other representing the height. These dimensions were then divided by the corresponding width and height of the image. The data table is organized such that each row represents the number of annotated objects.  
During data splitting, the dataset was divided into three subsets: test, train, and validation datasets. The reason for the validation and testing of the dataset was to avoid  
\begin{table}
\begin{tabular}{l c} \hline \hline
**Dataset Source** & **Number of Datasets** \\ \hline Brightness and contrast adjustment augmentation & 240 \\ Noise augmentation & 120 \\ Original dataset & 880 \\ TOTAL & 1240 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Number of the collected datasets and their respective sources.  
Figure 5: Data collection sample.  
the risk of overfitting. The dataset was split with a ratio of 80% for training and 10% each for validation and testing. Table 2 below depicts the total number of datasets.