Parking Management System with Number Plate Recognition using OpenCV in Python
Number Plate Recognition has been a recurrent research topic due to the increasing number of cameras available in cities, where most of them, if not all, are connected to the Internet. The video traffic generated by the cameras can be analyzed to provide useful insights for the transportation segment. This blog presents the development of an intelligent vehicle identification system based on Optical Character Recognition (OCR). The proposed system is integrated with a Parking Management System which is used to manage public or private spaces. Using Computer Vision techniques, the Parking Management System is used to detect if the parking slots are available or not and then assigns the closest parking slot to the recognized number plate of the vehicles that enter the parking lot.
Disclaimer: This blog is a proposed management system with a working code but does not completely automate the process. Manual intervention is required. This is a guide to our proposed system and not a ready made project to copy and paste. Prior knowledge of python and machine learning is required to be able to completely follow through!
Segments of this project:
- Detecting of number plate and character segmentation
2. Checking for availability of parking slots in the parking area
Segment 1
Step 1: Obtain image from CCTV or camera of the car entering the parking facility.
Step 2: Perform Image preprocessing. (The code is available at the end of this step.
Resizing the image is important for standardizing the image for pre-processing and image correction functions.
Greyscaling is done to reduce the computation for various image processes while retaining important information the image carries.
Noise reduction is used to improve the quality of the image be reducing noise/grainy distortions from the image to prevent misclassification and healthier input.
Canny edge detection is a technique to extract useful structural information from different vision objects and dramatically reduce the amount of data to be processed.
As the word “Binarization” suggests, the image is converted to complete black and white image based on threshold values set to segregate the background of the number plate from the characters present.
Step 3: Number plate localization and perspective transformation. (The code is available at the end of the step)
By locating the largest rectangle in the image, it is easier to locate the number plate in the image. This is a critical step for extracting the character segments of the number plate.
In Perspective transformation, we can change the perspective of a given image or video for getting better insights about the required information. In Perspective Transformation, we need provide the points on the image from which want to gather information by changing the perspective. We also need to provide the points inside which we want to display our image. Then, we get the perspective transform from the two given set of points and wrap it with the original image.
We use cv2.getPerspectiveTransform and then cv2.warpPerspective .
The custom functions that we have made for perspective transformation, correct the angle of the number plate of the vehicle to prevent morphing of the characters present inside.
Step 4: Number plate character extraction. (The code is available at the end of the step)
This is step segments each character of the number plate into appropriate sizes for running in the trained model. Image dilation is a process in which attributes of an image are “thickened” or more appropriately, expanded for better character recognition and decrease the chances of misclassification.
The list ‘a’ will return the extracted segments of the number plate.
Step 5: OCR using any kind of Neural Network model.
Build a model using a training dataset of characters and numbers. Run the extracted segments from the above code through your model to extract the characters from the number plate.
Example dataset: EMNIST
This is the end of Segment 1.
Segment 2
Step 1: Obtain image from CCTV or camera of the parking facility.
Step 2: Select ROIs for the possible parking slots in the facility.
Step 3: Label the ROIs based on distance or any convention you prefer.
Step 4: Identify whether the parking slot is occupied or not.
Step 5: Assign the entering car an available parking slot.
Conclusion
The system makes use of the parking management system which is a framework used to detect available parking slots using computer vision functions. The proposed system uses the camera to get the images and information of the parking slots. Once a vehicle enters the facility, the proposed system takes a picture of the vehicle and uses this image to identify the license plate number of the vehicle and then assigns the closest parking slot to mitigate wastage of time and fuel. The identified number is stored on the system, and this information can be made available to public agencies such as traffic departments. The algorithm used by the proposed system to detect the plate and to recognize the plate characters was described. The description starts with the plate image detection until the character recognition. The processing time to make the plate recognition is low, and the proposed system showed a good performance in a real environment. However, it was possible to verify that the character recognition is sensitive to the environment illumination, and to improve the accuracy, new experiments will be done considering other types of filters as well as new deep learning methods will be implemented in the future works.