gpt4 book ai didi

python-tesseract OCR : get digits only

转载 作者:太空狗 更新时间:2023-10-29 17:30:52 26 4
gpt4 key购买 nike

我正在使用带有 python-tesseract 的 tesseract OCR。在 tesseract FAQ 中,关于数字,我们有:

Use

TessBaseAPI::SetVariable("tessedit_char_whitelist", "0123456789");

BEFORE calling an Init function or put this in a text file called tessdata/configs/digits:

tessedit_char_whitelist 0123456789

and then your command line becomes:

tesseract image.tif outputbase nobatch digits

Warning: Until the old and new config variables get merged, you must have the nobatch parameter too.

在 python-tesseract 中,存在 SetVariable 方法。我已经试过了,但是 OCR 的结果是一样的:

api = tesseract.TessBaseAPI()
api.SetVariable("tessedit_char_whitelist", "0123456789")
api.Init('.','eng',tesseract.OEM_DEFAULT)
api.SetPageSegMode(tesseract.PSM_AUTO)

有没有人已经让它工作了,或者我应该认为它是 python-tesseract 中的一个错误?

最佳答案

好的,开始工作了。根据这个(unofficial ?) documentation对于 tesseract-ocr,SetVariable() 必须在 Init() 之后调用,尽管官方 FAQ 中的说法恰恰相反。在 Init() 按预期工作后调用它。

关于python-tesseract OCR : get digits only,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9794029/

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