I wish to extract the license-plate text from images using EasyOCR. I am obtaining license-plate images from a 2MP camera's stream placed atop traffic light poles. The final license-plate image's dimensions lie in the range of 70-100px by 25-60px.

The issue is that even in images where text is clearly visible, the OCR is not returning accurate results. How can I improve the OCR's results?

Results I am getting

enter image description here

My pipeline

I am performing the following preprocessing steps, which in order are:

  1. Grayscale conversion
  2. min-max normalization to increase contrast
  3. Detecting straight lines of license-plate's edges using Hough Transform and using them to rotate the image such that the text is straight (most of the time).

Using Binary Thresholding has given me worse outcomes so far. I have also tried using other varieties of thresholding. Gaussian/Median Blurring is making the problem harder since images are so tiny.

I am calling the EasyOCR's readtext() function and preprocessing like so:

from PIL import Image
import numpy as np
import cv2

image_pil = Image.open('image.jpg')
image = np.array(image_pil)

image_for_ocr = np.dot(image[...,:3],[0.2989,0.5870,0.1140]) ##-- Convert to grayscale

min_val = np.min(image_for_ocr)
max_val = np.max(image_for_ocr)
image_for_ocr = ((image_for_ocr-min_val)/(max_val-min_val))*255  ##-- Increase Contrast

image_for_ocr = np.clip(image_for_ocr, 0, 255).astype(np.uint8)

distance,angle = longest_hough_line(image_for_ocr) ##-- Return the distance from origin, and angle in radian of longest detected line in the image
image_for_ocr  = rotate_image(image_for_ocr, angle) ##-- Performs rotation of image about the centre, using the angle of the longest line

reader = easyocr.Reader(['en'], gpu=False)

detections = reader.readtext(license_plate_crop, decoder='greedy', detail=1, blocklist="~`/?\\|=+-_)(*&^%$#@!).-]{[}'" , contrast_ths = 0.5)
lp_text = ""
for detection in detections:
    bbox, text, score = detection
    text = text.upper().replace(' ', '')
    lp_text += text


I am fixing common errors in detections using dictionaries, because license-plates are of defined format:

dict_char_to_int = {'O': '0',
                    'I': '1',
                    'J': '3',
                    'A': '4',
                    'G': '6',
                    'S': '5',
                    'Z': '7',
                    'B': '8',
                    'Q': '0',
                    'P': '3',
                    'H': '4'}

dict_int_to_char = {'0': 'O',
                    '1': 'I',
                    '2': 'Z',
                    '3': 'J',
                    '4': 'A',
                    '6': 'G',
                    '5': 'S',
                    '7': 'Z',
                    '8': 'B'}

How can I increase the accuracy of the detections ?

Some sample images are as follows: enter image description here enter image description here enter image description here enter image description here



You must log in to answer this question.