我正在使用流行的 OCR tessercat fork for android tess-twohttps://github.com/rmtheis/tess-two https://github.com/rmtheis/tess-two。我整合了所有员工并且它有效等等......
但我只需要检测数字,我现在的代码是:
TessBaseAPI baseApi = new TessBaseAPI();
baseApi.init(pathToLngFile, langName);
baseApi.setImage(bitmap);
String recognizedText = baseApi.getUTF8Text();
baseApi.end();
doSomething(recognizedText);
从这里https://code.google.com/p/tesseract-ocr/wiki/FAQ#How_do_I_recognize_only_digits https://code.google.com/p/tesseract-ocr/wiki/FAQ#How_do_I_recognize_only_digits?
我使用的是 V3 版本,并且没有代码解决方案,而是一些命令行解决方案 - 与 android 项目无关(我认为......)。所以我尝试实现版本
baseApi.SetVariable("tessedit_char_whitelist", "0123456789");
我的问题是 init() 该怎么办?我不需要任何语言,但我仍然需要 init & aint init() 方法......
编辑:更具体地说
我的最终目标是纯文档(不是纯 Excel 工作表),看起来像所附图片(标题和 3 列以空格分隔)。
My requirements is to make sense in the digits: To be able to separate and determine which digits belong to which row and column.
Thanks,
我把它做得有点不同。也许这对某人有用。
所以你需要先初始化API。
TessBaseAPI baseApi = new TessBaseAPI();
baseApi.init(datapath, language, ocrEngineMode);
然后设置以下变量
baseApi.setPageSegMode(TessBaseAPI.PageSegMode.PSM_SINGLE_LINE);
baseApi.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "!?@#$%&*()<>_-+=/:;'\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
baseApi.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, ".,0123456789");
baseApi.setVariable("classify_bln_numeric_mode", "1");
这样引擎将只检查数字。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)