如何提高 EasyOCR 的准确性/预测?

k_p*_*k_p 2 python ocr text-extraction image-processing easyocr

我正在尝试从车牌中获取字符。但很少有错误的预测,比如

在此输入图像描述

我得到的输出为UP74 BD 3465,这是错误的。有许多B预测的例子8以及更多。

  • 如何提高其准确率?。
  • 如何预处理图像以获得正确的预测或任何其他方法?
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])
Run Code Online (Sandbox Code Playgroud)

Bil*_*lal 5

  • 首先,我建议您阅读有关 OCR 图像增强的主题:链接。

  • 其次,与上述主题相同,您可以使用Thresholding、Gaussian Filtering、 并在裁剪感兴趣区域 ( ROI )Histogram Equalization后解决此特定图像的问题,因此输出图像将如下所示:

在此输入图像描述

输出将是:

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])
Run Code Online (Sandbox Code Playgroud)