字母数字字符串的 Tesseract 配置:混合 2、Z、6 和 G

Tim*_*Tim 5 java ocr tesseract image-processing batch-file

我正在尝试配置 tesseract 以识别10 个字符长(全部大写)的字母数字字符串

这很有效,除了它似乎经常混淆以下字符:

  • 2Z
  • 6G

经过一些研究,我可能已经找到了原因(但我不确定):tesseract 中可能有一些系统可以根据字典(或其他数据)延迟的字符位置进行预测。我认为 Tesseract 可能会选择 a 而2不是 a,Z因为它看起来很喜欢,但也因为它总是出现在一个词中;2在这种情况下,a没有多大意义。至少这是我能做到的。

我想禁用它,所以我尝试了几个选项但没有运气:

tesseract = new Tesseract();                      
tesseract.setOcrEngineMode(TessAPI.TessOcrEngineMode.OEM_TESSERACT_ONLY);
tesseract.setPageSegMode(7);
tesseract.setTessVariable("load_system_dawg", "0");
tesseract.setTessVariable("load_freq_dawg", "0");
tesseract.setTessVariable("load_punc_dawg", "0");
tesseract.setTessVariable("load_number_dawg", "0");
tesseract.setTessVariable("load_unambig_dawg", "0");
tesseract.setTessVariable("load_bigram_dawg", "0");
tesseract.setTessVariable("load_fixed_length_dawgs", "0");

tesseract.setTessVariable("classify_enable_learning", "0");
tesseract.setTessVariable("classify_enable_adaptive_matcher", "0");

tesseract.setTessVariable("segment_penalty_garbage", "0");
tesseract.setTessVariable("segment_penalty_dict_nonword", "0");
tesseract.setTessVariable("segment_penalty_dict_frequent_word", "0");
tesseract.setTessVariable("segment_penalty_dict_case_ok", "0");
tesseract.setTessVariable("segment_penalty_dict_case_bad", "0");
Run Code Online (Sandbox Code Playgroud)

请注意,这是 Java 代码,但我的问题不仅限于 Java。

我对 Tesseract 并没有真正的经验,似乎发现文档很不清楚。我希望其他人可以帮助我。


提供更多背景信息:

我如何训练 Tesseract?

我通过将 200 多张图像组合成一张图像来训练 Tesseract。每个图像包含 10 个字母数字字符。另外,我确定盒子文件是正确的。

我通过执行以下批处理脚本来构建最终语言:

tesseract qwe.combined.jpg qwe.combined.box nobatch box.train

echo combined 1 0 0 0 0 > font_properties

unicharset_extractor qwe.combined.box

shapeclustering -F font_properties -U unicharset qwe.combined.box.tr

mftraining -F font_properties -U unicharset -O qwe.unicharset qwe.combined.box.tr

cntraining qwe.combined.box.tr

copy inttemp qwe.inttemp
copy normproto qwe.normproto
copy pffmtable qwe.pffmtable
copy shapetable qwe.shapetable

combine_tessdata qwe.
Run Code Online (Sandbox Code Playgroud)

我怎样才能让正方体区分之间的更好2Z6G