我想使用 tesseract 只识别数字。所以我将 tesseract 设置如下:
tesseract::TessBaseAPI tess;
tess.SetVariable("tessedit_char_whitelist","0123456789");
tess.Init(tessdata, "eng", tesseract::OEM_DEFAULT);
tess.SetImage((uchar*)im.data, im.size().width, im.size().height, im.channels(), im.step1());
const char* out = tess.GetUTF8Text();
但字母仍然出现在结果中。我是 tesseract 的新手,有人可以帮助解决我的问题吗?谢谢。
顺便说一句,图像有点旋转。
最佳答案
如果你想通了,我不是用户,但你的问题可能是你在 Init() 之前调用 SetVariable()?查看 baseapi.h 中的 SetVariable(),其措辞有点自相矛盾:
SetVariable may be used before Init, but settings will revert to defaults on End(). Note: Must be called after Init(). Only works for non-init variables (init variables should be passed to Init()).
所以我建议您尝试一下简单的重新排序,看看结果如何。
免责声明:我没有测试过,所以我不知道这是否是问题所在。
关于c++ - Tesseract API,白名单设置为数字但字母出现在结果中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33809104/