# Around View Monitoring-Based Vacant Parking Space Detection and Analysis
## 3 Algorithm to Detect Vacant Parking Spaces
### Space Occupancy Classification Stage
#### 3.3.2 Naive Bayes Classifier  
After extracting the features within the parking space, we need to classify the features to determine whether the space is vacant. Regarding our choice of classifier, although support vector machines have excellent classification performance, they involve relatively complex models and require manual manipulations of numerous parameters. Furthermore, classifying the status of a parking space is a simple binary problem. Thus, we chose the NB classifier, which is a simple model with satisfactory performance [28]. NB classifiers are based on Bayes theorem and the assumption of independence among features. [PERSON] theorem can be stated as follows:  
\[p(C|F_{1},\ldots,F_{n})=\frac{p(C)p(F_{1},\ldots,F_{n})[C)}{p(F_{1},\ldots,F_{ n})}, \tag{2}\]  
where \(C\) and F are the types and features of the training set, respectively. Because of the assumption that features are independent, Equation (2) can be rewritten as Equation (3), which can be simplified to Equation (4), which is the Bayesian probability model. \[p(C|F_{1},\ldots,F_{n})\propto p(C)p(F_{1}|C)p(F_{2}|C)p(F_{3}|C)\ldots; \tag{3}\]  
Figure 16: Obstacle feature extraction. \[\propto p(C)\prod_{i=1}^{n}p(F_{i}|C). \tag{4}\]  
The NB classifier is primarily composed of the model in Equation (4) and a corresponding decision rule. This rule states that the most likely possibility should be chosen. In the learning stage, the input is the training set and the outputs are the parameters that are required to be estimated for the classifier. To select appropriate parameters for the classifier from the training set, one can use maximum a posteriori (MAP) or maximum likelihood estimation (MLE). In this paper, MAP is used to estimate parameters for the decision rule of the Bayes classifier. The corresponding classifier is shown in Equation (5). \[classify(f_{1},\ldots,f_{n})=\underset{c}{\text{argmax}}p(C=c)\prod_{i=1}^{n}p (F_{i}=f_{i}|C=c), \tag{5}\]  
where \(C\) can be occupied or vacant, and \(F\) is the region growing ratio and number of edges. Figure 17a is the scatter plot of features for the perpendicular parking space training set. This figure shows that vacant parking spaces are characterized by high region growing ratios and low numbers of edges. By contrast, occupied parking spaces are characterized by region growing ratios that are not high and a more scattered distribution of numbers of edges. Figure 17b,c present the Gaussian distributions of region growing ratio and number of edges, respectively, for the perpendicular parking space training set. These figures show that parking spaces can be generally classified as vacant or occupied by these two features. Figure 18a is the scatter plot of features for the parallel parking space training set. The key difference between these results and the results of the perpendicular training set is that vacant parking spaces are no longer characterized by low numbers of edges. This is because edges in roadside parking spaces are inevitably affected by noise, such as concrete surfaces, storm drain covers, or manhole covers. Figure 18b,c present the Gaussian distributions of region growing ratio and number of edges, respectively. These figures show that the number of edges feature cannot be used to classify parking spaces as vacant or occupied. Figure 17: _Cont._  
Figure 17: Perpendicular parking training set. (**a**) Scatter plot of features; (**b**) Gaussian distribution of region growing ratio; (**c**) Gaussian distribution of number of edges. Figure 18: _Cont._  
Finally, Figure 19 shows the classification results using the NB classifier; red frames indicate occupied parking spaces and green frames indicate vacant parking spaces. Figure 19: Space occupancy classification results. Figure 18: Parallel parking training set. (**a**) Scatter plot of features; (**b**) Gaussian distribution of region growing ratio; (**c**) Gaussian distribution of number of edges.