Skip to content

Using morphological image processing and easyOCR to recognize license plates; Demonstrating the realtime detection with webcam in Google Colab.

Notifications You must be signed in to change notification settings

105304039/LPR_in_colab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LPR_in_colab

Open In Colab (Executing with GPU)
Using morphological image processing and easyOCR to recognize license plates; Demonstrating the realtime detection with webcam in Google Colab.

  • colab_LPR.ipynb demonstrates the execution in Google Colab
  • anpr_easy.py (reference) and colab_cam.py (reference) are files needed to be uploaded in Colab when we execute colab_LPR.ipynb

License Plates Recognition

This question can be divided into two parts: object detection and optical character recognition (OCR).

  • Object detection
    I use morphological image processing to detect the license plates according to the article on PyImageSearch (reference). In the article, the author uses blackhat morphological operation to reveals dark characters against light backgrounds. Then, Sobel operator, blurring, and closing are used to find boundaries of the characters and fill the holes, which locates the characters. Next, after a series of iterative erosions and dilations, the author uses light regions as a mask to reveal the license plate candidates. The author restricts the aspect ratios of the candidates since the aspect ratio are usually in certain interval. To accelerate the filtering process, I add one restriction regarding the lower limit of $\frac{\text{Area of Contours}}{\text{Area of Bounding Box}}$, which filters out the candidates on messy backgrounds.
    *Note: In real life the restriction of y coordinate can be useful since the license plates are close to the ground.
  • OCR
    I use easyOCR to perform OCR, specifying the allow list of the result. The easyocr.Reader(['en']) is not written in anpr_easy.py because it takes a while to download the detection model.

Webcam and Realtime License Plates Recognition in Google Colab

According to Colab_Webcam_OpenCV repository (reference), I edit the realtime_process() function to draw LPR results on the screen.
The execution in Google Colab is main.ipynb. Demo video is as below...
*Note: anpr_easy.py and colab_cam.py must be uploaded to the current Colab environment before we run main.ipynb.

image

About

Using morphological image processing and easyOCR to recognize license plates; Demonstrating the realtime detection with webcam in Google Colab.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published