# An Intelligent Smart Parking System Using Convolutional Neural Network

Authors: Ahmed A. Alsheikhy; Tawfeeq Shawly; Yahia F. Said; Husam Lahza
Journal: Journal of Sensors
 (2022)

---

## Abstract

Saudi Arabia has started building smart cities and communities as part of the Saudi 2030 vision, which aims to digitalize all services. Smart cities use different types of technologies and data to improve the quality of life for citizens, manage resources, and make operations more efficient. In big cities such as Riyadh and Jeddah, the number of vehicles on the road has dramatically increased. Hence, parking has become a problem since there are limited spaces available. In this article, a novel, intelligent, and automated method for vehicle parking and management is proposed. This approach employs a convolutional neural network (CNN) tool to train the algorithm deeply. Image segmentation and preprocessing techniques are employed as well. All operations are automated and cost-effective since the proposed smart parking management system utilizes only a single camera to provide real-time views of the status of a parking lot. Furthermore, there is no need for human interference, and it is easy to maintain. Several simulation scenarios were conducted on MATLAB to validate this approach and prove its efficiency. A comparative evaluation between the proposed system and some works of literature is provided, and it indicates that the developed system outperforms the works from the preexisting literature.


---

## Body

## 1. Introduction

There are many definitions for a smart city. A simple definition is that a smart city incorporates numerous technologies to provide a better life for citizens and improve the quality of services that are provided by the government [1, 2]. One of the goals of a smart city is to optimize all available resources for better civic life. It has been argued that simply providing more technologies creates a smart city, but the real value of a smart city lies in how these technologies are used [2–4]. The readiness of infrastructures, environmental initiatives, and the ability of people to be able to thrive are crucial characteristics of a smart city [4]. Figure 1 illustrates the various attributes of a real smart city [5].Figure 1
Concept of the real smart city.In Saudi Arabia, the government has started to build smart cities such as The Line City in Neom to achieve numerous goals. The main objectives of these projects are as follows:(1)
Transform traditional municipal services into smart ones to provide high-level services for citizens(2)
Improve the growth of the economy by attracting global investors in the country(3)
Provide long-term sustainability for the environment(4)
Enhance safety and security for the citizensIn accordance with Vision 2030, a strategic framework developed by the government in Saudi Arabia to diversify its economy and develop many public service sectors, numerous smart city initiatives have been announced by the Saudi government. These initiatives, including the development of waste management and smart parking systems, can be extremely beneficial in reaching the aforementioned objectives. The government seeks reliable solutions for the complex issues and challenges associated with the development and execution of its plan.Transportation management has become a particularly important issue in the present. The number of automobiles in Saudi Arabia has increased rapidly in recent years, which has raised concerns about fuel emission. The issue requires urgent solutions that provide environmental sustainability and reduce the impact of climate change. Searching for parking spaces leads to unnecessary fuel consumption, which harms the environment. The wasted time spent parking can also cause frustration for drivers, especially in big and busy cities such as Riyadh and Jeddah. Cities need feasible and reliable smart parking systems. Several solutions for smart parking have been developed to utilize available parking spaces in a city more effectively [6–9]. These systems are aimed at providing cost-effective solutions that will significantly reduce and minimize human labor [6].This article contributes to the problem by developing and presenting a novel approach for a smart car parking system that can be efficiently managed. This method is very cost-effective since there is no need to install sensors; it just requires one camera to provide real-time information about the parking area, either in images or video streams. These images or video streams are processed to identify the total number of vehicles in the parking area and to verify whether there are vacant spaces. Then, instructions are provided to drivers about the vacant spaces and where to park their vehicles. The proposed system employs a convolutional neural network tool called AlexNet. The AlexNet tool consists of eight layers: five convolutional layers and three fully connected layers. These are depicted in Figure2 [10]. Details about the proposed approach are provided in Section 3.Figure 2
AlexNet layers.The remainder of this article is organized as follows: Section2 presents the related work, and Section 3 provides details about the presented algorithm. Discussion and results are presented in Section 4, while Section 5 provides the conclusion.


## 2. Related Work

Biyik et al. [1] analyzed several proposed smart parking algorithms from a technical point of view, emphasizing their sensors and systems. Their objective was to deliver a comprehensive study of these methods. The authors claimed that the Internet of Things (IoT) technologies shall be used and given more attention in implementing smart car parking systems. Also, sensors are used as a major player in collecting information for the smart parking system. Interested readers can refer to [1] for more information.In [2], Patil et al. proposed a method for detecting vacant spaces in parking areas and managing automobiles that entered and left those areas. IR sensors were utilized to detect vehicles that moved in or moved out. A simple circuit was implemented to detect empty parking spaces and direct drivers to those spaces. However, this system was not cost-effective since every vehicle needed to have an IR sensor installed on it. In addition, human labor was still needed to operate and manage the system. In their proposal, a microcontroller, Arduino Uno R3, was used to connect all IR sensors together to process the collected data. A Wi-Fi module of MCU ESP 8266 was utilized to provide Internet service. The authors claimed that their model was an IoT-based approach since Internet service was employed and utilized. The proposed method herein is more cost-effective since it utilizes only a single camera, and there is no need for human labor as all operations are fully automated. In addition, Internet service is not required as all operations are handled automatically through a machine that runs the proposed system. Both systems, the proposed one herein and the implemented one in [2], provide the same functions; however, the presented system in this article is more cost-effective and easier to maintain. Readers can refer to [2] for more information about the developed method.Bassam and Samann [3] proposed a smart parking system using an optical character recognition (OCR) method. This system was implemented in three stages which included (1) detecting a vacant parking space based on OCR, (2) notifying drivers using an IoT mechanism, and (3) utilizing Simple Mail Transfer Protocol (SMTP) for smart parking meters. Every parking space was assigned a character, and vacant spaces were detected by a camera that was installed above the parking area. A morphology filter was introduced to improve the system’s performance by removing unwanted objects, whether big or small. Eight different images were used to test the accuracy of the proposed method, and it was found to be more than 90% accurate. However, this approach required every parking space to be labeled with a specific character, and it is costly as well. The presented algorithm in this article is fully automated and requires no labor to operate it at all. It similarly utilizes a Wiener filter to enhance the processing operation. Furthermore, the proposed approach determines how many vehicles are parked and how many vacant spaces exist with over 97% accuracy, according to the conducted simulation tests. Readers can refer to [3] for additional information.Nadipalli et al. [4] also presented an approach for a smart car parking system that employed IoT technology. The method involved using IR sensors to detect vehicles and available spaces. A microcontroller and a Wi-Fi modem were also utilized to carry out this approach. A cloud-based server updated the received sensor data and checked for vacant spaces online. This method updated its information every 10 seconds through the cloud-based server. This approach provided no real-time information since there was a delay of 10 seconds. When the microcontroller went down or there was no Wi-Fi, this method became completely useless [4]. On the other hand, the presented algorithm in this article relies on a single machine that can run a whole parking area. It can be used anywhere under any type of circumstance unless there is a power outage. In addition, it provides real-time data through captured images or video streams.In [5], Subramanian and Subashini proposed a ticket-based smart car parking method utilizing IoT technologies and a mobile application. Sensors were installed in parking areas to provide real-time information about vacant parking spaces. An SMS service was utilized to send notifications to drivers to inform them about vacant space allocations, directions, and billing rates. These sensors were installed in every parking lane to collect data. The system utilized an antenna and Internet service to operate and function properly. Hence, it would not work if no Internet was detected. Moreover, it was costly since multiple sensors were required to collect data. In this article, the presented algorithm requires no Internet service to operate as the camera is connected directly to the machine that holds the system. In addition, instructions for vacant spaces are provided as well. This system reaches over 97% of accuracy as proved by the applied simulation tests.Mohammadi et al. [6] implemented another method for securing a parking lot system using MATLAB and an image hashing technique. It contained two stages, one for scanning the parking area and another for securing data. The method showed the status of the parking area to drivers and motorists before entering and provided directions to available parking spaces. The hashing method was utilized to secure the system itself. A Raspberry Pi microcontroller was utilized to detect vehicles. An SD card and a board module were also employed to increase the rate of reliability of the implemented method. The authors utilized a 32-byte hashing key for authenticating purposes. In addition, no sensors were used to reduce the cost. The authors performed only two scenarios while four scenarios were conducted using the proposed system in this article. Readers can refer to [6] for more information.Sharma and Singh [11] implemented a fuzzy-based method for energy-aware WSN-based framework for smart parking systems. This design increased the network stability period by nearly 91.75% when compared with a low-energy adaptive clustering hierarchy (LEACH) protocol. In addition, it gained around 39% enhancement compared to the quantum ABC protocol. Readers can refer to [11] for additional information.Alharbi et al. in [12] highlighted the influence of parking vehicles on some streets and vital places in cities during traffic jams. In addition, they provided an automatic prereservation process for vacant parking spaces. This approach utilized an optical character recognition (OCR) algorithm to detect plate numbers and offered a web application. The authors applied their method in some streets in Saudi Arabia to reduce congestion. Interested readers can refer to [12] for additional information.Beed et al. in [13] presented a hierarchical Bayesian model to solve the multiobjective route optimization problem. This model worked with multinomial distribution and Dirichlet’s distribution prior to refining the weights in order to resolve the considered issue.Tabassum in [14] discussed a strategy to integrate the public transportation facilities provided by Riyadh metro with an element of smart city to form a Riyadh smart city (RSO) application. This integration process relied on a location-based service where a passenger was delivered. In addition, a web application was utilized to provide needed information to the passengers within their point of access. Readers can refer to [14] for additional information.


## 3. The Proposed Algorithm

In this section, details of the presented approach are provided. Figure3 illustrates the approach in a flowchart.Figure 3
Flowchart of the presented approach.Figure4 depicts a general parking lot map structure. The parking lot accommodates 10 vehicles in every lane; so in total, there are 60 vehicles.Figure 4
Parking lot map structure.The proposed system starts by taking data from the installed camera which provides real-time information. These images or video streams are fed into the algorithm, which starts the processing. If no vacant spaces are available, the system displays a message saying that the parking lot is fully occupied, and drivers must search for alternatives. The gate at the entrance remains closed. If there are empty spaces, the system opens the gate and provides directions to vacant spots where drivers may park their vehicles. The system additionally displays the total number of vehicles currently parked and the number of vacant spaces. The proposed algorithm is demonstrated as follows:Algorithm 1: Smart parking and management system.
Input: Real-time images.Output: Number of parked cars, number of vacant spaces, and directions to these spaces.1.Scan the parking lot every time a vehicle enters or leaves.2. If no vacant spaces are available, then3. Display a message to inform drivers and keep gate closed.4.Else5. Open the gate.6. Remove noise from captured image.7. Transform the resultant image into a gray image.8. Determine the dimensions of the parking area.9.End of preprocessing phase.10. Assign a number of vacant spaces to a threshold variable.11. Subtract captured image of current parking area from the parking map structure.12. Apply AlexNet for deep learning objective.13.For i =1: length of parking area14.For j =1: width of parking area15.Do the following:16.  Find resultant image from subtraction process and compare it with the threshold.17.If result > threshold, then:18.   Place 1 in the current index,19.Else20.   Place 0.21.End22.End23.End24. Check which lanes have vacant spaces to direct drivers to the nearest one.25. Display instructions for drivers or motorists to park their vehicles in the detected lane.26.End of algorithm.The advantages that can be obtained from the presented system are as follows:(i)
Very cost-effective(ii)
Environmentally friendly since it decreases fuel consumption, power, and energy dissipated(iii)
Easy to maintain and operate(iv)
It can be integrated with other systems easily(v)
Additional features such as checking the parking area ahead of arrival, booking a vacant space, and adding billing components can be added with minor changes in the system designThe proposed system requires fewer operations to run and manage its features; thus, its execution time is less when compared to other methods in the literature. Furthermore, it is cost-effective as it utilizes only a single camera that sends its data in real-time to the connected machine. This system is intelligent since it employs the convolutional neural network tool to train itself and adapt to any type of conditions and circumstances that may exist such as a traffic accident or car failure inside the parking lot or a vehicle that parks in the driveway which could lead to a deadlock. Once an abnormal activity inside the parking area is detected, then the considered team such as the administration team is alerted and notified to take proper action. Since the implemented system depends and relies on a single camera, thus its fault tolerance can be considered low. This drawback is resolved by having a backup camera that comes up immediately once the system detects no inputs from the main camera for a long time. An alternative way is to rely on a human intervention to take control manually if the installed camera goes down for any reason.


## 4. Results and Discussion

Numerous simulation experiments were carried out in MATLAB to verify the workflow of the developed algorithm and test its accuracy and efficiency. These experiments were conducted on a machine that runs Windows 11. The machine was an 8th-generation Intel Ship with a 2 GHz processor and 16 GB of RAM. Two figures were drawn using a software that is compatible with Windows 11. In these two figures, vehicles are represented asX during the simulation runs, where X can refer to a vehicle of any size or a motorcycle. Four different scenarios are presented in this article to demonstrate the effectiveness of the proposed approach. Scenario 1 represents a full parking lot in which there is no vacant space while Scenario 2 demonstrates a scenario where there are vacant spaces in one of the lanes and a driver is directed there. In addition, two real parking lots with vehicles were downloaded from Google [15] and utilized to validate the presented algorithm on real scenarios. These scenarios are shown in Scenario 3 and Scenario 4, respectively.


### 4.1. Scenario 1

Figure5 illustrates Scenario 1 in which the parking lot is full, and drivers should search for another one. This parking lot accommodates 60 vehicles in 6 lanes as shown in Figure 5. The system shows a message to drivers to inform them about the status of the parking lot and keeps the gate closed.Figure 5
Obtained results for Scenario 1.


### 4.2. Scenario 2

The parking lot is already occupied with 53 vehicles, and it can accommodate 7 vehicles before reaching its maximum capacity. The proposed algorithm processes a new vehicle and provides outputs as depicted in Figures6 and 7.Figure 6
Obtained results for Scenario 2.Figure 7
Complete status of the parking lot.The developed approach shows the nearest available lane that has vacant spaces (lane 6) and displays the total number of parked vehicles in it as well. Figure5 shows three subgraphs while Figure 6 shows four subgraphs. This occurred since there was no vacant lane in Scenario 1 to display while Figure 6 displays that there are vacant spaces in lane 6, and this lane is shown in the subgraphs as well. Hence, the developed approach detected the lane and displayed it with its current parked vehicles.


### 4.3. Scenario 3

Figure8 demonstrates the real parking lot with vehicles on the left side and its corresponding map construction on the right side. This parking lot accommodates a maximum of 53 vehicles, and it currently has 32 vacant spaces.Figure 8
Real parking lot of Scenario 3.Figures9 and 10 depict the obtained outputs for Scenario 3.Figure 9
Resultant images for Scenario 3.Figure 10
Numerical results for Scenario 3.The proposed approach seeks vacant spaces in all lanes and selects one to which drivers are directed. In Scenario 3, lane 1 has vacant spaces. After the driver is directed to that lane, a message displays the current status of the parking lot, as demonstrated in Figure10.


### 4.4. Scenario 4

In this scenario, the parking lot includes dedicated parking spaces for trucks in lane 5 and lane 6. This is depicted in Figure11. The parking lot contains 82 spaces in total: 10 spaces for trucks and the rest for other vehicles, as shown on the left side of Figure 11. The figure also shows that the parking lot has 28 vacant spaces for regular vehicles and 6 vacant spaces for trucks. Hence, there are 34 vacant spaces in total. Note that regular vehicles are considered in this scenario, but trucks can be considered as well.Figure 11
Real parking lot of Scenario 4.Figure12 shows the output images of Scenario 4 as obtained from the implemented algorithm in this article. Figure 13 depicts the numerical results.Figure 12
Resultant images of Scenario 4.Figure 13
The obtained numerical results of Scenario 4.Figure13 demonstrates that the proposed approach searches every lane to find vacant spaces and it starts from lane 1 to lane 4. Lane 1 has vacant spaces, and they are detected by the implemented algorithm.Since the proposed algorithm in this article only requires one camera to operate and provide its outputs, it is incredibly cost-effective. Other developed works in the literature reviewed above use IoT sensors, a far more expensive technology, to detect vacant spaces. In contrast, because CAMs are so inexpensive, the method that is being provided here costs practically nothing. A camera with a high-quality lens costs less than $20 in Saudi Arabia. In addition, the effectiveness of the alternative methods relies on Internet or Wi-Fi services which is a disadvantage. The operations would suffer if any of these services were to go down for any reason, and they might even become temporarily unavailable. On the other hand, because the CAM is directly connected to the operating system, the proposed algorithm in this work does not require Internet or Wi-Fi access to function. This guarantees that there will not be any service interruptions unless an operating computer experiences an unforeseen problem. Even in this situation, the proposed approach is still more practical than the methods that have been discussed in the literature. In terms of the methodology used, utilized equipment, accuracy, and cost, Table1 compares the proposed system in this paper with relevant works from the literature.Table 1
Comparative evaluation results.
WorkEvaluation criteriaMethodologyUtilized equipmentAccuracyCostPatil et al. [2]Image segmentation and preprocessingArduino, IR sensors, and Wi-Fi moduleNot mentionedExpensiveBassam and Samann [3]Optical character recognitionCamera, web server, email server, DB, and Internet service>90%ExpensiveNadipalli et al. [4]Image segmentation and preprocessingIR sensors, DC motor, Wi-Fi modem, and microcontrollerNot mentionedExpensiveSubramanian and Subashini [6]IoT and image segmentation and preprocessingDB, Internet service, mobile phone, wireless sensors, and serverNot mentionedExpensiveThe proposed systemCNN and image segmentation and preprocessingSingle camera>97%Cheap


## 4.1. Scenario 1

Figure5 illustrates Scenario 1 in which the parking lot is full, and drivers should search for another one. This parking lot accommodates 60 vehicles in 6 lanes as shown in Figure 5. The system shows a message to drivers to inform them about the status of the parking lot and keeps the gate closed.Figure 5
Obtained results for Scenario 1.


## 4.2. Scenario 2

The parking lot is already occupied with 53 vehicles, and it can accommodate 7 vehicles before reaching its maximum capacity. The proposed algorithm processes a new vehicle and provides outputs as depicted in Figures6 and 7.Figure 6
Obtained results for Scenario 2.Figure 7
Complete status of the parking lot.The developed approach shows the nearest available lane that has vacant spaces (lane 6) and displays the total number of parked vehicles in it as well. Figure5 shows three subgraphs while Figure 6 shows four subgraphs. This occurred since there was no vacant lane in Scenario 1 to display while Figure 6 displays that there are vacant spaces in lane 6, and this lane is shown in the subgraphs as well. Hence, the developed approach detected the lane and displayed it with its current parked vehicles.


## 4.3. Scenario 3

Figure8 demonstrates the real parking lot with vehicles on the left side and its corresponding map construction on the right side. This parking lot accommodates a maximum of 53 vehicles, and it currently has 32 vacant spaces.Figure 8
Real parking lot of Scenario 3.Figures9 and 10 depict the obtained outputs for Scenario 3.Figure 9
Resultant images for Scenario 3.Figure 10
Numerical results for Scenario 3.The proposed approach seeks vacant spaces in all lanes and selects one to which drivers are directed. In Scenario 3, lane 1 has vacant spaces. After the driver is directed to that lane, a message displays the current status of the parking lot, as demonstrated in Figure10.


## 4.4. Scenario 4

In this scenario, the parking lot includes dedicated parking spaces for trucks in lane 5 and lane 6. This is depicted in Figure11. The parking lot contains 82 spaces in total: 10 spaces for trucks and the rest for other vehicles, as shown on the left side of Figure 11. The figure also shows that the parking lot has 28 vacant spaces for regular vehicles and 6 vacant spaces for trucks. Hence, there are 34 vacant spaces in total. Note that regular vehicles are considered in this scenario, but trucks can be considered as well.Figure 11
Real parking lot of Scenario 4.Figure12 shows the output images of Scenario 4 as obtained from the implemented algorithm in this article. Figure 13 depicts the numerical results.Figure 12
Resultant images of Scenario 4.Figure 13
The obtained numerical results of Scenario 4.Figure13 demonstrates that the proposed approach searches every lane to find vacant spaces and it starts from lane 1 to lane 4. Lane 1 has vacant spaces, and they are detected by the implemented algorithm.Since the proposed algorithm in this article only requires one camera to operate and provide its outputs, it is incredibly cost-effective. Other developed works in the literature reviewed above use IoT sensors, a far more expensive technology, to detect vacant spaces. In contrast, because CAMs are so inexpensive, the method that is being provided here costs practically nothing. A camera with a high-quality lens costs less than $20 in Saudi Arabia. In addition, the effectiveness of the alternative methods relies on Internet or Wi-Fi services which is a disadvantage. The operations would suffer if any of these services were to go down for any reason, and they might even become temporarily unavailable. On the other hand, because the CAM is directly connected to the operating system, the proposed algorithm in this work does not require Internet or Wi-Fi access to function. This guarantees that there will not be any service interruptions unless an operating computer experiences an unforeseen problem. Even in this situation, the proposed approach is still more practical than the methods that have been discussed in the literature. In terms of the methodology used, utilized equipment, accuracy, and cost, Table1 compares the proposed system in this paper with relevant works from the literature.Table 1
Comparative evaluation results.
WorkEvaluation criteriaMethodologyUtilized equipmentAccuracyCostPatil et al. [2]Image segmentation and preprocessingArduino, IR sensors, and Wi-Fi moduleNot mentionedExpensiveBassam and Samann [3]Optical character recognitionCamera, web server, email server, DB, and Internet service>90%ExpensiveNadipalli et al. [4]Image segmentation and preprocessingIR sensors, DC motor, Wi-Fi modem, and microcontrollerNot mentionedExpensiveSubramanian and Subashini [6]IoT and image segmentation and preprocessingDB, Internet service, mobile phone, wireless sensors, and serverNot mentionedExpensiveThe proposed systemCNN and image segmentation and preprocessingSingle camera>97%Cheap


## 5. Conclusion

The presented approach in this article is highly useful for traffic management in smart cities, as illustrated by the previous scenarios. It is easy to operate and maintain and can be utilized anywhere. In addition to the parking services, a billing system can be easily integrated into the technology to determine a rate and charge drivers for access to the parking lot. The integration of a driver notification system is also possible with minor adjustments. MATLAB is used to validate the proposed method, and its results show that the novel method proposed here performs as intended and produces accepted outputs.



---

*Source: 7571716-2022-11-21.xml*