Tesseract 在相当清晰的图像上失败
Tesseract Failing on reasonably clear image
我一直在尝试将 Tesseract OCR 与 Open CV (EMGUCV C#) 结合使用,并且我正在尝试提高可靠性,总的来说它一直很好并且通过一次应用各种过滤器并尝试 OCR(原始, Bilateral, AdaptiveThreshold, Dilate) 我似乎有了显着的改善。
然而...
下图很顽固,尽管看起来很清楚,但我没有从 Tesseract 得到任何结果(滤镜前的原始图像):
在这种情况下,我只是在 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)
我一直在尝试将 Tesseract OCR 与 Open CV (EMGUCV C#) 结合使用,并且我正在尝试提高可靠性,总的来说它一直很好并且通过一次应用各种过滤器并尝试 OCR(原始, Bilateral, AdaptiveThreshold, Dilate) 我似乎有了显着的改善。
然而...
下图很顽固,尽管看起来很清楚,但我没有从 Tesseract 得到任何结果(滤镜前的原始图像):
在这种情况下,我只是在 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)