我一直在尝试使用Tesseract光学字符识别与Open CV (EMGUCV C#)相结合,我试图提高可靠性,一个整体它是很好的,通过应用各种过滤器一次一个和尝试光学字符识别(原始,双边,AdaptiveThreshold,扩张)我似乎有了显著的改善。
然而..。
下面的图像很顽固,尽管看起来很清楚,但我从Tesseract (滤镜之前的原始图像)得不到任何结果:
在这种情况下,我只是想要2.57
发布于 2020-09-22 11:05:39
与在图像上使用滤镜不同,缩放图像在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)
https://stackoverflow.com/questions/63997033
复制相似问题