image-processingautomatic-license-plate-recognitionopenalpr

what's the proper way to make openALPR to read plates in different angles?


I'm using openALPR library to read plate licenses but I'm having issues reading the plates in different angles, like below image. My question is: what's the proper way to do that? Image processing to try make the image straight before submitting such as Homography ? openALPR's settings such as max_plate_angle_degrees max_detection_input_width, max_detection_input_height, etc or train the tesseract-ocr with cropped images in different angles? I have no code to show because I'm looking for a direction how to do that.

enter image description here

enter image description here


Solution

  • Yes, Homography is the general term for what you are looking for, but I think you might find better resources by searching for "geometric transformation" or "projective/perspective transformation".
    Here are some starting resources that might help:

    1. Understanding Homography (a.k.a Perspective Transformation) - Towards Data Science
    2. Geometric Transformation of Image - OpenCV Tutorials
    3. Applying perspective transformation and homography - Packt (soft paywall)

    I don't know about OpenALPR, and can't find clear documentation anywhere, so I can't comment on it. But those functions you've listed (max_plate_angle_degrees max_detection_input_width, max_detection_input_height) does not sound like what you are looking for.

    And I personally don't recommend training Tesseract OCR directly on unprocessed images (uncropped, angled license plates). Typically, you would follow an image processing procedure before passing it to Tesseract OCR as the final step. However, I haven't touched Tesseract since version 3 back in 2018, so the latest version 5 might fare better...


    Regardless, I would imagine a traditional, end-to-end image processing pipeline like this:

    1. Image capture
    2. Preprocessing of image brightness, contrast, and colors
    3. Cascade classifiers to quickly detect & locate license plates (also filters out images without license plates)
    4. Crop image to the detected license plate
    5. Edge and corner detection
    6. Identify control points with Hough transform (finding 4 corners of license plate through line intersections)
    7. Estimate homography matrix with linear algebra (most image processing libraries should already have this function for you)
    8. Projective transform on image from step (4) with the estimated homography matrix
    9. Tesseract OCR on transformed image to extract license number

    You would likely implement fewer steps than this, as most libraries provide higher level functionalities that handles all this automatically.