Project for Image Processing Course. The goal of the project is to recognize polish license plate from an image.
- the angle between horizontal surface and license plate is +- 45 degrees
- longer edge of license plate is greater than 1/3 of image's width
- license plate has 7 characters
- images can have diffrent resolutions
- written in Python 3.7 using OpenCV
- there's an option to use other libraries (like scikit-image) but you cannot use external OCR modules or trained models that can read characters
- maximum time for each image processing is 2 seconds
- Bounding box accuracy of license plate: 96,42% (27/28)
- Bounding box accuracy of characters in license plate: 91,32% (179/196)
- Total score: 86,42% (Every correct read character on license plate -> 1 point. Correct read of whole license plate equals to 1 point for each character + 3 additional points.)
- Total score: 63.70% (Every correct read character on license plate -> 1 point. Correct read of whole license plate equals to 1 point for each character + 3 additional points.)
- execution time per image: 0.11s
- Create virtual environment using
python3 -m venv venv
- Install requirements from
requirements.txt
- Run script with
python main.py <path_to_folder_images> <path_to_json_results_file>
- convert to gray scale
- resize the image for faster processing
- blur image and find image edges.
- find contours on the image
- create bounding boxes from contours
- skip bounding boxes that doesn't match license plate height to width ratio
- get corners of potential license plate
- construct destination points based on vertices
- get perspective transform matrix
- warp the perspective getting bird's eye view in a process
- find contours on the image
- get bounding box of each contour
- discard all small bounding boxes and bounding boxes that don't match character width to height ratio
- discard contours in contours
- sort potential characters ROIs from left to right
- compare ROI of each potential character with reference characters and get closest matching
- if there's more ROIs than maximum license plate length, delete character with weakest matching
- if there is no maximum number of characters found, fill empty spaces with "?". "?" are filled in proper space based on distance between each character
- compute distance between ROIs to determine number of characters in first part of license plate
- change forbidden characters to theirs closest counterpart. For example 2 -> Z in first part of license plate