I am trying to get characters from vehicle number plate. But getting few wrong predictions like

I am getting output as UP74 BD 3465, which is wrong . There are many examples where B is predicted as 8 and many more.
import matplotlib.pyplot as plt
import easyocr
from pylab import rcParams
from IPython.display import Image
rcParams['figure.figsize'] = 8, 16
reader = easyocr.Reader(['en'])
output = reader.readtext(path)
for i in range(len(output)):
print(output[i][-2])
Firstly, I suggest you to read this topic about image-enhancement for OCR: LINK.
Secondly, In the same sense of the topic above you can solve it for this particular image using Thresholding, Gaussian Filtering, and Histogram Equalization after you crop the region of interest (ROI), so the output image will look like:

and the output will be:
UP14 BD 3465
import cv2
import easyocr
from pylab import rcParams
# import numpy library
import numpy as np
# define the path
path = 'input.png'
# read the image
img = cv2.imread(path, 0)
# find the white rectangle
th = img.copy()
th[th<200] = 0
bbox = np.where(th>0)
y0 = bbox[0].min()
y1 = bbox[0].max()
x0 = bbox[1].min()
x1 = bbox[1].max()
# crop the region of interest (ROI)
img = img[y0:y1, x0:x1]
# histogram equalization
equ = cv2.equalizeHist(img)
# Gaussian blur
blur = cv2.GaussianBlur(equ, (5, 5), 1)
# manual thresholding
th2 = 60 # this threshold might vary!
equ[equ>=th2] = 255
equ[equ<th2] = 0
# Now apply the OCR on the processed image
rcParams['figure.figsize'] = 8, 16
reader = easyocr.Reader(['en'])
output = reader.readtext(equ)
for i in range(len(output)):
print(output[i][-2])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With