Tesseract无法获得合理清晰的图像

问题描述

我一直在尝试将Tesseract OCR与Open CV(EMGUCV C#)结合使用,我一直在尝试提高可靠性,这是一件好事,并且一次应用了多种过滤器,然后尝试进行OCR(原始,双边) ,AdaptiveThreshold,Dilate),我似乎有了很大的进步。

但是...

以下图像很固执,尽管看起来很清晰,但我没有从Tesseract得到任何结果(过滤器之前的原始图像):

enter image description here

在这种情况下,我只是在2.57之后

解决方法

缩放图像确实可以对OCR有所帮助,而不是对图像使用滤镜。下面是我尝试的代码。抱歉,我使用linux,我使用python而不是C#进行测试

#!/usr/bin/env python3
import argparse
import cv2
import numpy as np
from PIL import Image
import pytesseract
import os
from PIL import Image,ImageDraw,ImageFilter


ap = argparse.ArgumentParser()
ap.add_argument("-i","--image",required=True,help="Path to the image")
args = vars(ap.parse_args())
img = cv2.imread(args["image"])

#OCR
barroi = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
scale_percent = 8 # percent of original size
width = int(barroi.shape[1] * scale_percent / 100)
height = int(barroi.shape[0] * scale_percent / 100)
dim = (width,height)
barroi = cv2.resize(barroi,dim,interpolation = cv2.INTER_AREA)

text = pytesseract.image_to_string(barroi,lang='eng',config='--psm 10 --oem 3')
print(str(text))
imageName =  "Result.tif"
cv2.imwrite(imageName,img)

enter image description here