gpt4 book ai didi

ocr - tesseract 5.0 bazaar + 用户词配置不起作用

转载 作者:行者123 更新时间:2023-12-04 17:43:43 25 4
gpt4 key购买 nike

我试图强制 tesseract 在执行 OCR 时只使用我的单词列表。
首先,我将集市文件复制到 /usr/share/tesseract-ocr/5/tessdata/configs/ .这是我的集市文件:

load_system_dawg F
load_freq_dawg F
user_words_suffix user-words

然后,我创建了 eng.user-words/usr/share/tesseract-ocr/5/tessdata .这是我的用户词文件:
Items
VAT
included
CASH

然后我通过命令对这个图像执行 ocr: tesseract -l eng --oem 2 test_small.jpg stdout bazaar .

test_img

这是我的结果:
2 Item(s) (VAT includsd) 36,000
casH 40,000
CHANGE 4. 000

如您所见, includsd不在我的用户词文件中,它应该被“包含”。此外,即使不使用 bazaaz 我也得到了相同的结果在命令中配置。看起来我的 bazaareng.user-words config 对 OCR 输出没有任何影响。那么如何使用 bazaaruser-words配置,以获得想要的结果?

最佳答案

您需要做的就是对图像进行上采样。
如果你上采样两次
enter image description here
现在阅读:

2 Item(s) (VAT included) 36,000
CASH 40,000
CHANGE 4,000
代码:
import cv2
import pytesseract

# Load the image
img = cv2.imread("4nGXo.jpg")

# Convert to the gray-scale
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Up-sample
gry = cv2.resize(gry, (0, 0), fx=2, fy=2)

# OCR
print(pytesseract.image_to_string(gry))

# Display
cv2.imshow("", gry)
cv2.waitKey(0)

关于ocr - tesseract 5.0 bazaar + 用户词配置不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59307205/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com