Implementation of an Available Parking Space Detection System in Hectic Parking Lots

Parking automation has been developed for locating available parking spaces inside a parking lot with new technologies, such as automatic collection, capacity, or empty spaces’ detection; to both reduce search time and avoid crowds of vehicles waiting to park in it. A simple detection system of available spaces, within the Faculty and Staff parking lot of the Engineering and Chemistry Departments at the Autonomous University of Chihuahua, Mexico (UACH), was set up. First, an analysis of vehicle capacity was carried out to establish the peak hours of vehicles’ entrances and compare it to the parking lots’ capacity. For one working week (6 days), it was determined that Tuesdays have the highest vehicle occupancy, and Saturdays are the days with the least traffic. Second, the geometric design of the parking lot (divided into two areas because of the terrain topography: upper and bottom levels), its dimensions and location of parking spots and marks on the pavement for traffic directions, were obtained from its blueprint, to visualize how the surveillance cameras can be oriented to cover the area. A detection system prototype was created for a specific area of the parking lot, using an artificial vision technique to perform the video extraction, while the digital image processing was developed in MATLAB. To complement and achieve the objective, ObjectOriented Programming (OOP) was used to obtain the count analysis as well as the availability/occupancy of each of the parking areas. This information is shown on a web page, with a simple driver-friendly design, since it has each parking space number and its availability in blue with the word “Available” or, in the opposite case, the word “Taken” in pink.


Introduction
Worldwide university communities grow yearly, and the Autonomous University of Chihuahua (UACH) is no exception. In the past decade, enrollment has grown from approximately 26,000 students in 2010 to 29,180 by 2019 [1], increasing along with it the need for parking spaces. UACH's Engineering and Chemistry Departments, the object of this study, has parking space issues during peak hours, with drivers wasting a lot of time locating where to park. Due to these arguments, a need to implement an intelligent system arises, which allows drivers to easily and quickly visualize where there are places available, thus optimizing times, reducing accidents and CO 2 emissions. Drivers in big cities spend an average of 20 minutes hunting for a parking space [2], making parking one of the most inefficient daily activities. A study realized by the company INRIX in 2017, Americans spent about 17 hours a year hunting for parking spots, and they wasted around 345 dollars in time, fuel, and emissions [3]. Globally, this inefficiency has big consequences in our lives: 30% of urban traffic is generated by drivers looking for parking [4], in average, more than 50 hours per driver are spent looking for a parking spot annually [5]; the time and fuel wasted costs consumers and local economies about $600 million US dollars per year [5]. Bill Ford, Executive Chairman of Ford Motors, warned in 2011 that "the freedom of mobility is being threatened", since the world fleet of 800 million cars will grow to 2 -4 billion by 2050, when 75% of the population will live in cities. This will lead to a "global gridlock", which "will stifle economic growth and our ability to deliver food and healthcare". The solution to this challenge is not to build more roads, but to develop smart roads, smart public transportation, and smart parking [6].
Automation inside parking lots has allowed drivers to be comfortable and safe, using programmable technology [7] [8] [9]. These techniques provide various tools, such as the use of a digital platform with a guide detection of empty spaces system, to indicate which parking spot is available or occupied within the parking lot. This project developed an available spaces detection software prototype for a small area within the Faculty and Staff parking lots at UACH's Engineering and Chemistry Departments. With the development of an application, it was possible to detect empty or occupied parking spots, through a driver-friendly web page. The main purpose of this research was to contribute and benefit the UACH's community and to improve the service to the vehicle fleet. Additionally, to reduce the driving stress to all staff and students, while helping find available space to leave your vehicle in a safe and timely manner.

Background
Since the end of the 19th century, specifically in 1885, when the first vehicle was built, and in 1889, when the first car making companies were created, automobiles have been considered as the main means of transport [10]. Since the 1990's, the number of private vehicles has increased to such an extent that it has ex-Journal of Transportation Technologies ceeded the capacity of the road infrastructure of urban centers. This has made circulation more difficult, therefore generating large parking demands, leading to the need to adapt automation within a vehicular parking system [11].
Parking automation is considered the global trend procedure to solve the above-mentioned issues. Implementing new technologies, such as automatic collection, capacity, or empty spaces' detection, within public spaces, are some of the solutions being implemented to this date [12]. In the case of public parking lots, with a rate according to its time of use, automation turns out to be a good business, while for private parking lots, is also considered as an opportunity area for administration and optimization, to automate services and/or control of access and exits [13].

Current Parking System in Mexico
In Mexico, most of the parking lots do not have highly structured systems, since access control is generally done manually, causing the availability of spaces to be validated through a personal review. However, to improve the parking service, as a minimum, a basic model is required, in which generally there is a surveillance booth, operated manually [14]. Whether or not there is a security booth, at least one person must be present at the parking lot's access point, responsible for providing information about whether there are enough parking spaces available and delivering a ticket with the date and time of entry. However, there are places where only a ticket is provided, and the driver must circulate through the whole parking lot until an empty space is located. This model could also be improved by adding the use of automatic barriers and card/ticket readers [14].

Applicable Technology in Parking Lots
Current technological advances developed to optimize parking lots include pass printing and automatic payments, efficient lighting systems, intelligent systems to find available parking spots, and even chargers for electric vehicles [12]. To run a system or application that specializes in empty spaces' detection, the Arduino platform implementation, with artificial vision or video detection, and a Radio Frequency Identification (RFID) technology was implemented [15] [16].
It should be considered, however, how these systems typically present high costs for installation and execution [16].

Smart Parking Systems in Latin America
In Latin America, some projects have been carried out, such as in the Pontifical Catholic University of Peru (in 2008), where a vehicle detection system for a parking lot was developed, recognizing the presence of cars through a detection sensor that was installed in the access lane and another in the exit lane, limiting vehicles to enter and exit using the same lane [17]. In Ecuador in 2011, the National Polytechnic School developed the PROPARK tool. This system enables searches in any smart phone, users can find the closest parking spot to their lo-Journal of Transportation Technologies cation, as well as availability of other unoccupied places. Its operation requires global positioning system (GPS), wireless technologies such as Bluetooth, and consultation through text messages (SMS) [18]. In 2012, the Army Polytechnic School (Mendoza and Romero, 2012) presented an artificial vision system, which consists of an image processing system, which allowed or denied access to vehicles wishing to enter the university. All information is processed in data analysis system [19]. Also, in the National Polytechnic School of Ecuador (2014), a smart vehicle accommodation system was designed through video recording and the implementation of a test prototype. After digital images are processed in the application, through matrices, recognizing the parking area of each of the available and occupied spaces, thus providing a result to the app user [20].

Smart Parking Systems in Mexico
In 2011, the Technological Institute of Aguascalientes presented a project where the main goal was to automate and provide support for greater security to achieve vehicular access control. The automation works with RFID technology, a radio frequency identification card, with a unique and unrepeatable number, which manages to provide security [21]. Also, a proposal for smart parking based on sensors with internet in the Malecon area and downtown Mazatlán, was developed by the Autonomous University of Sinaloa, using an optical photoresistor sensor (LDR). It works with light interruption, if an obstacle interrupts the passage of light, the LDR increases its resistance and interrupts passage of current through the control circuit. These are installed in each parking spot and then connected to the Internet via Wi-Fi. Later, a mobile application in Microsoft C # language and the .NET platform were developed since it is cross-platform for optimal operation [22]. In 2018, a parking space counting prototype was developed at Puebla's Iberoamerican University. An optical sensor was placed in each parking space, it detected the presence of a person or an object that interrupts light reaching the sensor, which use solar cells to charge the sensors' batteries. For the LED lamp panels, red and green LEDs were used to signal the system. In addition, resistors, an Arduino Uno system (which is necessary for the counter programming) were used [23].

Methodology
The main goal of this project consisted in developing an accessible and not expensive parking spot detection system prototype. The study area included only the parking spaces reserved for Faculty and Staff at the Engineering Department at UACH (Figure 1). To complete the prototype development, the project was carried out in several stages, where each of them needed to be finished before starting the next one.

Geometric Design
The geometric design of the parking lot facilities was visualized both in situ and digitally. It was possible to recognize the entire area with the bay designs and each parking space location. An interesting fact about this parking lot is that all vehicles must be parked in reverse, making the system's goal easier. It is also necessary to mention, that the parking area is not homogeneous, since it has spaces separated by narrow connectors and differences in elevation, in addition to the access point, with a booth, located in its middle section.
First of all, it was necessary to generate an inventory of all available parking spaces, and due to the complexity of the parking lot's terrain, it was divided into two areas: area "A", made up of all the space located to the west of the access booth, only accessible through a card reader sensor west of the booth; and area "B", which encompasses the surface located to the east of the booth, the Chemistry Department parking space, as seen in Figure 2.
Parking spaces were grouped by color following their function, others by their geometry and usage. The colorless parking spots in Figure 2 are those available without restrictions. The ones in green are reserved for pregnant women and seniors; and those in blue are reserved for people with disabilities or wheelchairs.
Finally, the spots shown in red are reserved for institutional vehicles such as cars, busses, vans, etc. In addition, there are some parking spots poorly drawn and with a size that does not correspond to standard measurements. Furthermore, some spots are designated for official vehicles (busses, vans, or even trucks). Table 1 shows the distribution of parking spots by parking area. According to the different existing categories it was possible to determine capacities for both area A and area B.   to area B, where 4 pneumatic tubes were used for 6 days. After all this, the gauges with their respective pneumatic tubes were removed, data was downloaded, and files were transferred from the counter to a computer using the Vehicle Identification and Analysis System (VIAS software). The data was organized in tables and graphs, where it was classified according to date, hour, and number of vehicles, allowing to distinguish peak hours, total capacity and, above all, vehicle rotation.

Machine Vision and Video Processing
The parking lot in question has a surveillance camera that can only monitor area A at its top (Figure 3), so the prototype only focuses on this zone. All information provided by the camera was acquired, and those videos that focused the parking spots with a clear line sight were delimited. Having the artificial visualization of the study area, several scenarios were considered, such as the empty parking lot, the parking maneuvers, and a completely packed parking lot, to be able to process the video through the images obtained. Once the video is captured, it is converted to a sequence of images (JPEG files). The Ffmpeg program for Windows needs to be downloaded; then, work with the commands Prompt (cmd) and Ffmpeg to convert the video into images. The video is trimmed to Journal of Transportation Technologies obtain the necessary images and they must be placed in the same folder where the video is, to work with them at the same time.

Object-Oriented Programming (OOP) in MATLAB
To create the empty spaces' detection program, a reading and writing images execution algorithm was developed using an Object-Oriented Programming (OOP) within MATLAB 2016. First thing done was to extract the "base" image that is represented by the empty parking lot, giving it a numerical value starting from the left side to the right side (Figure 4(a)). Subsequently, the cursor delimits the area of each of the parking spots, determining their X and Y coordinates, in addition to creating a polymask to make the comparison with other images where time has elapsed (Figure 4(b)).
This polymask was designed in a binary way through the drawn polygon

Webpage
A website was created to show users the available parking spots, and which ones are already occupied, allowing the drivers to go to the place where can park with no loss of time. In addition, the representative way of the results was modified using only the parking space number (0 or 1). The number 1 is used for spots not available and number 0 for the free ones, which is saved in the text file.
The development of the steps to create the web page is represented in a flowchart ( Figure 6). The Wampserver software was used, it served as an auxiliary to have a server on the laptop, and to process all the previous analysis in MATLAB.
With the help of the test server, it was possible to assess different web designs, and make changes quickly. The web page can be accessed from the local network or by enabling the accessibility settings from the internet with an IP address. It was necessary to have all the files on the web page in a folder inside the Wampserver server document root folder (wamp64), as well as the MATLAB processing Journal of Transportation Technologies Continuing with the webpage code, a loop with a control variable was applied ($i), starting with number "0" and repeating until reach the number of parking spots analyzed. Additionally, a basic function was executed to subtract the characters, and with the help of the conditioning "if", it was able to evaluate the numbers, leaving "0" for available and "1" for taken spots. Finally, with the help of Quixlab graphic interface, it was possible to create a friendly visual representation of empty parking spots for users.

Vehicle Capacity Analysis
Vehicle counting in and out of the parking lot, as mentioned above, was carried out in a 24/7 for an entire week. The hour with the highest incidence of entries during the week was detected from 7:00 am to 10:00 am (Figure 7(a)). Unlike the hours of entry, the peak hours of departure varied according to the day, although it is constant between 13:00 and 15:00, and between 18:00 and 21:00 with a different magnitude, as appreciated in Figure 7  Comparing the parking lot capacity with the vehicle counting analysis, it is notable how during mornings of weekdays, finding an available parking spot without delay gets more complicated. Is during these "congested times" when the proposed detection system would help greatly.

MATLAB Analytic Tests
Several tests were performed using the algorithm created in MATLAB, to assure the correct operation. Above all, it was possible to reach the exact count of the availability in each of the parking spaces in different images. As can be seen in the upper portion of Figure 8, four spots are occupied/taken: 3, 4, 5 and 6 and the rest are free, in addition, this same interpretation appears in a text box using numbers 1 and 0, as previously explained (Figure 8 below).

Functional Tests of the Website
When entering the localhost/app address or the ip/app/address in the browser, just press enter to view the web page as shown in Figure 9.
Shown in the prototype webpage are the parking slot number, a drawn car, and a text box. If the parking spot is available, it is presented with a blue car accompanied by a text box of the same color with the word "Available". If the spot is occupied, the spot is represented with a pink car and a text box of the same color displaying the word "Taken". Then there is a button to update the information shown in the page. This prototype webpage needs to be improved by adding a map of the parking spot numbers, as suggested by the test users.

Conclusions
This project allowed designing a simple parking detection system prototyping in a crowded parking lot. Only the use of a camera, a computer, digital data processing, and free software support is required. It is possible to detect and report the available parking spaces in a parking lot through image processing. This search system provided the parking spot's availability, allowed quick decision-making when looking for parking spaces alternatives, avoiding the stress of searching the entire area to find an available place. It also helps in reducing CO 2 emissions and, increases productivity while reducing parking related stress for the UACH's Staff.
Machine vision and image processing eased the prototype design, so it was possible to manipulate images from a video, to understand their relationships with a function attached to MATLAB. With the SURF detector, it was possible to extract the characteristic and relevant points of an image, then later determine if there is an object or not. In addition, throughout the development process, functionality tests were performed by making a visual comparison with images, thus corroborating the detection system. With the polymask binarization, essential for the program to run efficiently, it was possible to discriminate unnecessary information outside the parking spaces, and in turn, generate the coordinates and the specific area for each parking spot, to make the analysis and avoid delays in executing it with so much information.
Effects caused by changes in environmental lighting while image processing, was a variable not evaluated in this research, since it may cause many problems, especially in night shifts, as the prototype had a conflict with the shadows of the trees during daylight. This remains as a future work point. A user-friendly web page allowed to show the final data obtained in the prototype, so that it can easily be seen by users, on digital media such as computers, tablets and/or cell phones.