繁体   English   中英

我怎样才能提高这种图像的 tesseract 的准确性?

[英]How can i increase the accuracy of tesseract for this kind of image?

我正在尝试使用 PIL 和 pytesseract 从视频游戏中获取文本。 这是我要识别的示例:

在此处输入图像描述

我用一个基本的 function 来获得二进制图像,另一个来反转它,这里是 function:

@staticmethod
    def getBinaryImage(image, thresh):
        fn = lambda x: 255 if x > thresh else 0
        im = image.convert('L').point(fn, mode='1')
        return im

使用这些过滤器,我设法得到这个:

在此处输入图像描述

问题是 tesseract 无法识别这一点。 我尝试了二进制图像的不同阈值,但它没有帮助。

我的问题是,是否有任何其他基本过滤器可以应用于我的图像以使其质量更好并让 tesseract 识别它?

编辑:

这是我的图像的新版本,已调整大小。 但是tesseract还是认不出来。

在此处输入图像描述

我使用 tesseract 和 best way on OCR 它在你的排版上训练。 您可以使用参数执行解决方案的另一种方法:

--psm N
Set Tesseract to only run a subset of layout analysis and assume a certain form of image. The options for N are:

0 = Orientation and script detection (OSD) only.
1 = Automatic page segmentation with OSD.
2 = Automatic page segmentation, but no OSD, or OCR. (not implemented)
3 = Fully automatic page segmentation, but no OSD. (Default)
4 = Assume a single column of text of variable sizes.
5 = Assume a single uniform block of vertically aligned text.
6 = Assume a single uniform block of text.
7 = Treat the image as a single text line.
8 = Treat the image as a single word.
9 = Treat the image as a single word in a circle.
10 = Treat the image as a single character.
11 = Sparse text. Find as much text as possible in no particular order.
12 = Sparse text with OSD.
13 = Raw line. Treat the image as a single text line,
     bypassing hacks that are Tesseract-specific.

然后使用 --psm 10

另一种方式:

--oem N
Specify OCR Engine mode. The options for N are:

0 = Original Tesseract only.
1 = Neural nets LSTM only.
2 = Tesseract + LSTM.
3 = Default, based on what is available.

这个 oem 选项在 tesseract 4 和 5 上可用,根据我的经验,我不能使用这个选项导致错误我想使用 --oem 0,所以我安装了 tesseract 3.2,它是 --oem 0 的最后一个版本,我变得更好预测

这是我的经验,试试吧。 我希望这个对你有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM