Tesseract OCR,读取 low-resolution/pixelated 字体(尤其是数字)

Tesseract OCR, reading a low-resolution/pixelated font (esp. digits)

我正在尝试使用 Tesseract OCR v3.2 来识别计算机屏幕上的字符,但使用某种低分辨率字体给我带来了很多麻烦,尤其是涉及到数字时。字体看起来像 this. I am currently putting input images through a 4x upscale with a bicubic filter in Python, which results in them looking like this。 Tesseract 将处理后的图像读取为“12345B?89D”。

我尝试了各种其他高档比率(高达 1000%),以及其他图像过滤器,如 lanczos、锐化、平滑、边缘增强和抗锯齿。 None 产生了更准确的结果。任何人对如何提高对该字体的识别有想法吗?

只是厌倦了使用您的小型和放大 (x4) 图像提供给 Tesseract 4.0.0a。小的即使调整了 Tesseract 参数也没有输出。升级版能够在所有测试的三种情况下进行 OCR - 无需进一步处理,灰度化并进一步增强。

使用的 Tesseract 集成到 OpenCV 3.2.0。以下是代码。

import cv2
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline 

def show(img):
    plt.imshow(img, cmap="gray")
    plt.show()

def ocr(img):
    # Tesseract mode settings:
    #   Page Segmentation mode (PSmode) = 3 (defualt = 3)
    #   OCR Enginer Mode (OEM) = 3 (defualt = 3)
    tesser = cv2.text.OCRTesseract_create('C:/Program Files/Tesseract 4.0.0/tessdata/','eng','0123456789',3,3)
    retval = tesser.run(img, 0) # return string type
    print 'OCR Output: ' + retval

# Directly feed image to Tesseact
img = cv2.imread('./imagesWhosebug/SmallDigits-x4.png')
ocr(img)

# Load image as gray scale 
img = cv2.imread('./imagesWhosebug/SmallDigits-x4.png',0);
show(img)
ocr(img)

# Enhance image and get same positive result
ret, thresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY) 
kernel = np.ones((3,3),np.uint8)
img = cv2.erode(thresh,kernel,iterations = 1)
show(img)
ocr(img)

输入图像和 OCR 结果在此处。