Smart and efficient system for the detection of wrong cars parking

Received May 13, 2020 Revised Apr 29, 2021 Accepted Jun 26, 2021 This paper presents a smart and efficient car-parking detection system. The proposed system is comprised of two cameras connected to a mobile system that is devised with Arduino, four DC motors, and PIR sensor placed strategically to monitor parking space, especially within its painted rectangular lines of each parking lot. The mobile monitoring system is automatically responsive to any move they detected as vehicles within the parking space along the rows of parking lots. Once detected, the captured images are processed using the MATLAB software. Any improperly parked cars detected, the cameras will identify their plate numbers, and snap and record it in a database. The designed prototype of the proposed system was tested in five presumed cases. In each case, ten images were processed, thus 50 images were eventually obtained. Out of the 50 images, 48 images corresponded to correct detection whereas the other two images corresponded to wrong detection. Accordingly, the efficiency rate of the proposed smart carparking monitoring system is 96%. This system offers suitable solution in assisting drivers to park properly within each parking lot and owners of parking area to keep it organized via remote monitoring system.


INTRODUCTION
Nowadays, the world population is growing rapidly as well as their vehicles. These vehicles need to be parked in parking area or its lots where an area dedicated for parking, either unpaved or paved with durable or semi-durable surface. In most countries where cars are the dominant mode of transportation, parking lots complement the set of public amenities of every city and suburban area. Commonly, wide parking area is provided nearby or within shopping malls, sports stadiums, big mosques, and similar locations. Depending on the location of the parking area, the allowed parking time may be fixed by regulation and a fee may be required for using the parking lot [1]. As well, some areas may be designated for free parking. Organizing parking areas by hiring some employees may incur additional time, effort, and money costs. Improper parking means taking two parking lots or not parking correctly and/or in the right place. So, competent authorities need to impose certain fine on the parking violators.
Many methods have been utilized to organize and manage the parking lots, one of them is segmentbased homogeneity model. It assumes that a vacant parking place has a homogeneous appearance [2]. There are sensors detecting improper parking termed "vehicle detection" when it attempts to park using costly expensive multiple stationary cameras [3]. Consequently, this proposed system aims at overcoming this problem by using only two moving cameras instead based on its plate number. Nowadays, such smart parking systems require less human intervention. However, some of the past proposals used ultrasonic detectors or image-processing techniques e.g., Yong (2014) used the ultrasonic sensor to detect the car park availability for drivers to swiftly locate vacant parking lots. His proposed system was named smart parking system (SPS) contains a set of directional indicators to the vacant car parking lots, available parking lot display, vacant car park detection, improper parking detection, payment facilities, and different types of parking spaces by using LED indicator [4].
Another study, Mustaffa (2012) used the ultrasonic sensor to detect each individual car parking lot, which is fixed on the ceiling above it that functions based on echolocation. It transmits a sound that hits a solid object (car or ground) which is reflected back to the sensor. The longer time lag between the sent pulse and the returned echo is equated with distance, means it is a vacant space and vice varsa [5].
T. N. A. M. Pham et al., is regulated by algorithmic cloud-based SPS based on the internet of things (IoT) technology that increases its capability, is user-friendly, and economic based on a new performance metric: carmatic [6]. This metric calculates the occupied spaces of car park. The data includes the GPS location of each vehicle, its distance among car parking lots, and available parking lots are sent to the data center. Its cloud server calculates the fee the parker needs to pay according to the duration of time it is parked. This data is regularly updated and informed on the board to the users. It operates independently as a regular car park. The system is in fact, based on a system model with wireless access in an open-source physical computing platform based on Arduino with RFID technology. The feasibility of this system was evaluated by smart phone usage that connects between the cloud and the vehicles users [6]. P. M. R. ha Deoghare [7], a smart parking area system based on image processing was developed for parking lot detection based on an image-processing technique that captures and processes the brown rounded image drawn at the parking lots and reports vacancies. There are seven informative segments regularly updated on the LED signboard displaying the number of the available parking lots in the parking area [7]. It also has line detection system, or improper parking detection system, which consists of two sensors for each parking lot oriented horizontally along the lines demarcating the left and right boundaries of the space. If any car is parked on the line, then the sensor triggers an alarm and the driver should adjust her/his car within the lines until the beeping sound stops. However, the entire system seems in need of smart improper parking detection systems to complete the set [5]. The system suggested in [8] corresponds to a simple SPS that monitors cars and identifies wrong parking using ultrasonic sensor, PIR motion sensor, Arduino, and LCD touch screen to display the results. The SPS takes a signal from three ultrasonic sensors in a moving Arduino, analyzes it, and converts it into a code. The moving Arduino then sends the code by using wireless radio frequency to a fixed Arduino, which the proposed system displays using the LCD touch screen to view the analysis results. If any car mistakenkenly parked, the display will show red line. The vacant park will be displayed as a black car and the correctly-parked car will be displayed as a green car [8].
A new method for locating texts in images with complex backgrounds has been presented. It efficiently combines MSER and a locally adaptive threshold method. The result is a connected-componentbased approach that extracts basic letter candidates using a series of easy and fast-to-compute features. These features, after being extracted from a challenging train of dataset which contains different texts in a huge variety of situations, proved to be following a Gaussian distribution. This means that they can be used with any dataset independently from their sizes, colors, or font types. This proposed method was tested on four different datasets. The testing results confirmed competitiveness of the method. Unlike other methods, this method has the advantage of reuseable feedback in order to restore those characters that might have been filtered out erroneously after computing the text features for each candidate letter. It was also proposed to use a classifier based on simple features like the mean, standard deviation, and HOG computed over image blocks so as to remove the repeating structures that can be easily confused with the text lines such as bricks and fences [9].
H. Chen et al. [10], a novel algorithmic text detection is proposed that employs maximally stable external regions (MSERs) as basic letter candidates. The sensitivity of the MSER with respect to image blur and to detect even very small letters is overcome by inventing an edge-enhanced MSER, which exploits the complimentary properties of MSER and Canny edges. Moreover, a novel image operator is combined to accurately determine the stroke width of binary CCs. This proposed method has demonstrated state-of-the-art performance in locating text in natural images. The detected text is binarized letter patches, which can be directly used for text recognition purposes. Additionally, this system can be efficiently composited into visual search systems by sharing MSER as interest regions [10]. Meanwhile, a system was proposed based on PC with video camera in [11]. It produces video frames including a visible car license plate and processes them. Once a license plate is detected, its digits are recognized, and displayed on the user interface or checked against a database. The focus is on design of algorithms that can be used for extracting the license plate from a single image, isolating the characters of the plate, and identifying the individual characters. The purpose of the system is to serve as a real time application that recognizes license plates from cars at a gate, for example at the entrance of a parking area or a border crossing. This proposed system was operated using Vision Assistant 8.2.1 & LabVIEW 11.0. Its recognition accuracy of vehicles amounting to about 98%, which confirms its efficiency [11].
Conclusively, a smart system comprises of cameras, Arduino, a direct current (DC) motor, and an infra-red (IR) motion sensor is sufficient to organize and manage parking lots. The camera mainly plays a vital role to guide incorrect car parking after detection and identification of its plate number. Plus, incorporating Arduino, which is an open-source platform [12] used for constructing and programing electronics circuits [8], [13]- [20].

METHODOLOGY
The smart parking system presented in this paper employs image-processing techniques in the MATLAB environment. It is very flexible to correspond to the future technological advancement since the technology can save a lot of time for the drivers with less efforts from the traffic management personnel. This system is designed on an Arduino Mega 2560 [21]. This Arduino chip is incorporated into other components such as PIR motion sensor [22], four DC motors [23] with their shields [24] forming a mobile system that moves when the sensor senses a motion. Two cameras are fixed in that mobile system, one on the right side of the mobile system, and one on the left side. These two cameras connect with a computer, which performs some processing operations using MATLAB. This computer is connected to the Arduino by USB. Figure 1 is a flowchart that explains the workflow of the herein proposed system and briefs its operations. The block diagram in Figure 2 describes this system. The proposed smart parking system works as: a. A car enters the parking area, whether an underground or a multi-story park. b. The PIR sensor senses the object motion within a circle of 360 degrees, then sends signal to the Arduino. c. The Arduino (Arduino Mega 2560) sends a command to the DC motors. d. The DC motors start moving and, accordingly, the mobile system moves step by step starting from point A to point B (end point) as shown in Figure 3. e. Two cameras are fixed in the mobile system and connected to a PC. These two cameras capture two images from a live video for two different parks from two different directions, left and right for each step. f. The captured images are then processed by MATLAB and image-filtering techniques are used to remove any noise and produce a filtered image. g. The image is converted from RGB into a binary image and the small objects are removed. h. The centroids of the cars in the image are determined. i. All objects are removed except the middle object (car). j. Then, the middle object is removed, and all the lines are detected. k. After that, the car that is located directly in front of the camera and which is in the middle of the image is detected and the process of parking is started. l. A check is made of whether one of the two lines or both disappeared or of whether or not the width of the car is bigger than the parking length. m. If no, then the parking is correct, and processing of this image is completed. However, if yes, then the parking is wrong and the process of detection of the plate number of the car starts as the next step. n. The image is converted from RGB to the grey scale. o. Afterwards, the candidate text regions are detected using MSER function in MATLAB (detectMSERFeatures) that finds all the regions within the images including many stable regions that are not text. p. The non-text regions are removed based on stroke width variation (SWV), which is a common metric used to discriminate between text and non-text features. Stroke width is a measure of the width of the curves and lines that make up a character. Text regions tend to have little stroke width variation whereas non-text regions tend to have larger variations. q. Next, the text regions are merged for final detection. The individual text characters must be merged into words or text lines. r. Then, the detected text is recognized using OCR function. s. Finally, the extracted text (number) is saved in a dropbox file named 'recordsc1' in the system so that this file can be shared with the relevant authorities. t. The previous operation is iterated until the mobile system reaches point B. Then, it returns to point A.
A simple model of parking system is proposed in Figure 3. It composed of five parking lots located on both right and left sides. However, it has no extra space in the experiment other than the one mentioned. If there are five cars parking in the parking spaces in the right side Figure 3, then when a car enters the parking area, the PIR sensor senses a motion, and the Arduino sends a command to the DC motors to move step by step from point A to point B. As Figure 3 illustrates, the car in the parking lot number 5 in right side is parking wrongly. Therefore, the number of that car is detected as shown in Figure 4. More details about car plate number detection can be found in [25], [26]. Detecting whether one of the two lines or the two lines are disappeared. Or the width of the car was bigger than the parking length.

4
Detect text regions on image using MSER Remove non-text regions by stroke width variation metric Recognize detected text using OCR The extracted text (Number) is saved in a dropbox file named recordsc1 so that it can be shared

Yes
Merge the text regions The mobile system moves a step forward or backward based on the status The parking is correct The parking is wrong   In this work, the mobile camera has been used to capture the vehicle platform through IP camera application. The methodic steps to detect the vehicle plate number using OCR recognition technique within MATLAB toolbox are described as: a. The candidate text regions are being detected by MSER: its detecting feature works well to recognize them due to its consistent and high contrast color onto the text area, which leads to stable intensity profiles. This function plots all the results of the images within the regions. There will be some area that is empty around the text as in the original image of the vehicle as shown in Figure 5. b. Its non-text regions based on basic geometric properties: are being mostly removed by the MSER algorithm after detecting the stable regions of text in the image as shown in Figure 6. c. Stroke width variation method is also used to remove non-text regions based on common metric to discriminate between text and non-text. Stroke width is a measure of the width of the curves and lines that make up a character. Text regions tend to have little stroke width variation, whereas non-text regions tend to have larger variations. In order to help understand its usage to remove non-text regions, the stroke width of a detected MSER regions was estimated as an example. It can be measured using a distance transform and binary thinning operation. A binary image of the region will be padded to avoid boundary effects during the stroke width computation. The result is shown in Figure 7. d. Text regions are merged for final detection result: at this point, all the detected results are comprised of individual text characters, such as OCR, the individual text characters have been merged into words or text lines. This enables recognition of the actual words in an image to provide meaningful information rather than just the individual characters, e.g., the string of letters for 'EXIT' vs. a set of individual characters alone. A common method in merging individual text regions into words or text lines is to first detect neighboring text regions and then a bounding box is formed around these regions. These boxes will be merged when computed together with region props to find neighboring regions. This overlaps the bounding boxes of neighboring text regions of such text regions as manifested in Figure 8. e. Detected texts are recognized by OCR: Note that without first finding the text regions, the output of the OCR function would be considerably noisier. The result of this step is given in Figure 9.  Figure 9. Recognition of detected text using OCR

RESULTS AND DISCUSSION
The smart parking system proposed in this work is using a real time mobile system, which provides recommendations about car parks to the customer in order to organize and manage the parking lots as given in Figure 10. The mobile system is composed of four DC motors and DC motor shield connected to the Arduino (Arduino Mega 2560) and a PIR motion sensor also connected to it as illustrated in Figure 10. The Arduino board was connected with a computer to activate Arduino program, the instructions can be uploaded to the Arduino, thus, maintains being mobile system to a particular distance and then, come back to the same point. An image-processing toolbox captures an image by a camera and processes it in MATLAB.
The proposed design was tested to check its performance efficiency using (1) and image processing capabilities in detecting the wrong cars parking. The mobile system moves, and the fixed camera captures an image from a live video. Then, this image is processed in MATLAB. If there is a car in the parking area, then it will be detected and whether or not it crosses the line is checked. If it crosses the line, then the car plate number will be captured. This proposed design is a model of a real-life parking area. It underwent five experiments. The results of each experiment (or case) were recorded. A description of these five experiments and their results is presented next.

Experiment 1
In this experiment, all the cars were parked in a proper way as depicted in Figure 11. The results of smart parking system are elaborated in detail in Table 1. These results derived from the above design procedure as discussed in the previous section. Figure 10. Photograph of the mobile system Figure 11. Photograph of experiment 1 setup

Experiment 2
In the second case as shown in Figure 12, the car in parking lot number 3 on the left side and car in parking lot number 4 on the right side were parking in improper way. The red arrows in Figure 12 point to the improperly-parked cars. The measured results of the proposed parking system are summarized in Table 2. As shown in Figure 12, the car in parking lot number 3 on the left side as well as the car in parking lot number 4 on the right side were detected as improperly-parked cars and recorded in the database for further process. Figure 13 shows the detected plate numbers of the cars.

Experiment 3
In the third case, the car in parking lot number 3 on the left side is parking in proper way as shown in Figure 14, but upon processing it appeared as if it was crossing the line. Therefore, it was detected as wrongly-parked car and its plate numbers were captured. The car in parking lot number 1 on the right side was parking in improper way as demonstrated in Figure 15. For each park, if the improperly-parked car was detected with its number, then the detection efficiency for that single park is 10%. However, if the improperly-parked car was detected but its number was not captured, or was wrongly captured, then the detection efficiency becomes 5%. The red arrows in Figure 14 and Figure 15 indicate the improperly-parked cars. Table 3 shows the measured results of experiment 3.  Figure 14. Experiment 3 setup (right side) Figure 15. Experiment 3 setup (left side) In the fourth case, the car in the parking lot number 2 on the left side is parking in improper way as shown in Figure 16. So, it was detected but its number was not. Cars in the parking spaces number 3 and 5 on the right side are parking in improper way Figure 17, and they were correctly detected with their numbers. Car in parking lot number 2 on the right side is parking in proper way, but it was detected as wrongly parking with its number captured. For each park, if the improperly-parked car was detected with its number, then the detection efficiency for that single park is 10%. However, if the improperly-parked car was detected but its number was not extracted, or was extracted wrongly, then the detection efficiency becomes 5%. The red arrows in Figure 16 and Figure 17 point to the improperly-parked cars. The measured results of the proposed parking system applying experiment 4 are elaborated in Table 4.

Experiment 5
In this experiment, the car in parking lot number 2 on the left side is parking in proper way Figure  18, but it was detected as wrongly parking. Meantime, the car in parking lot number 5 on the left side is parking in improper way Figure 19. It was correctly detected so. The cars in the parking spaces 1, 3, and 5 on the right side are parking in improper way. In consequence, they were detected with their numbers. Table 5 displays the measured results of this experiment. Table 6 compiles the experimental results for all cases. In each of the five cases, the experiment was repeated four (4) times. The results shown in Table 6 uncover that the proposed system is highly effective and efficient with an average detection percentage of 96%. The system proposed here is considered as a modern system that can be utilized in real life to ensure proper parking and identify improperly parking cars by their plate numbers. Each case was independently studied, and its efficiency calculated. Then, the average efficiency was calculated. Apparently, the efficiency results explained in Table 6 support that the smart car parking system proposed herein has a high efficiency and that it, accordingly, successfully achieves the goals of the study. In conclusion, the proposed car-parking system has better overall performance compared to the other car parking systems recently reported in [8], [27]. Furthermore, the measured results show that the proposed system is smart, efficient, and more capable in detecting the wrong cars parking, thus, organizing and controlling the parking lots at lower cost. Also, this proposed system offers possible solutions to equip the car with a mobile smart parking monitoring system that can help the driver in parking her/his car correctly in the allotted parking space.

CONCLUSION
Several problems are associated with parking, mainly including lack of parking areas in cities and wrong parking. In order to solve this problem, engineers invented many methods that are constantly being developed. In this study, a smart car parking system was proposed and tested. This system utilizes camera to monitor cars and detect those improperly parking. The proposed system has two cameras fixed in a mobile system which is composed of four DC motors, Arduino, and PIR motion sensor. The mobile system moves only if the PIR sensor catches a motion. It moves from point A to point B and then back to point A. During this motion, the two cameras capture images from a live video for each parking space. The images are processed by the MATLAB image-processing toolbox so as to detect improper parking. If parking is improper, then the plate number of the wrongly-parked car is captured and saved in a Dropbox file named record1. The measured results show that the proposed system is highly effective and efficient with an average detection percentage of 96%. The performance testing results showed that the proposed system successfully achieved its objectives. Several benefits are obtained from using this system, for instance detecting the improperly parked cars, and facilitating efficient management of the parking areas at a low cost.