Pytesseract 将一组字符串列入白名单

发布于 2025-01-20 07:40:57 字数 924 浏览 2 评论 0原文

我正在尝试从报告中的报告中检测文本作为图像。该报告始终具有相同的结构。

例如 请参阅下面的图片

“在此处输入图像描述”

Google找到的示例。

实际报告主要包含来自航空业的内部缩写,而Pytesseract无法正确识别。

该程序必须仅识别CC,C1,...,参数名称(字符串列表) +数字。因此,基本上,我正在寻找一种将几个字符串和所有数字的白人主义者的方法。这是在Pytesseract中指定的可能性吗? 到目前为止,我只找到了Tessedit_char_whitelist,不幸的是,这对我没有帮助。

到目前为止,我所做的事情:

import cv2
import pytesseract as pt
import pandas as pd
import numpy as np

filename = 'Rep15_4.jpg'
img = cv2.imread(filename)


# best resutls!!!
#config = r'--oem 1 --psm 4'
# or
#config = r'--oem 1 --psm 6'
# or 
#config = r'--oem 3 --psm 4'

config = r'--oem 3 --psm 4'
text = pt.image_to_string(img, config = config)

对于配置,我尝试了OEM和PSM的所有选项。最重要的是,我试图用CV2 - &GT来操纵图像。 cvtcolor,高斯布鲁尔,阈值。最有问题的是0个值。

感谢您的帮助。

I am trying to detect text from a report safed as image. The report always has the same structure.

e.g.
See picture below

enter image description here

Example found by google.

The actual report contains mostly internal abbreviations from the aviation industry which are not recognized correctly by Pytesseract.

The program must recognize only CC, C1, ..., Parameter Names (list of Strings) + numbers. So basicly im look for a way to whitelist a couple of strings and all numbers. Is this possibe to specify in Pytesseract?
So far I have only found tessedit_char_whitelist, which unfortunately does not help me.

What i have done so far:

import cv2
import pytesseract as pt
import pandas as pd
import numpy as np

filename = 'Rep15_4.jpg'
img = cv2.imread(filename)


# best resutls!!!
#config = r'--oem 1 --psm 4'
# or
#config = r'--oem 1 --psm 6'
# or 
#config = r'--oem 3 --psm 4'

config = r'--oem 3 --psm 4'
text = pt.image_to_string(img, config = config)

For config i have tried all options for oem and psm. On top i tried to manipulate the image with cv2 -> cvtColor, GaussianBlur, threshold. Most problematic are the 0 values.

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文