Creating a training image for Tesseract OCR

2019-03-16 13:10发布

I'm writing a generator for training images for Tesseract OCR.

When generating a training image for a new font for Tesseract OCR, what are the best values for:

  1. The DPI
  2. The font size in points
  3. Should the font be anti-aliased or not
  4. Should the bounding boxes fit snugly: enter image description here, or not: enter image description here

标签: ocr tesseract
3条回答
▲ chillily
2楼-- · 2019-03-16 13:47

Good tool for tesseract training http://vietocr.sourceforge.net/training.html

It is good tool because having number of advantages

  1. bounding box on letter can be editable by GUI based interface
  2. automatically create all require file
  3. automatically combined all files like freq-dawg, word-dawg, user-words (can be empty file), Inttemp, Normproto, Pffmtable, Unicharset, DangAmbigs (can be empty file), shapetable into single eng.traineddata file.
  4. New training data can be used with existing tesseract file end.traineddata
查看更多
做个烂人
3楼-- · 2019-03-16 14:01

I found the answer to the 4th question - "Should the bounding boxes fit snugly".

It seems that fitting the rectangles as much as possible gives much better results.

For the other 12 pts and 300 dpi will be good enough, as @Yaroslav suggested. I think anti-aliasing is better turned off.

查看更多
甜甜的少女心
4楼-- · 2019-03-16 14:08

The 2th question is somehow answered here: http://code.google.com/p/tesseract-ocr/wiki/TrainingTesseract3#Generate_Training_Images There is no need to train with multiple sizes. 10 point will do. (An exception to this is very small text. If you want to recognize text with an x-height smaller than about 15 pixels, you should either train it specifically or scale your images before trying to recognize them.)

Questions 1 and 3: by experience, I've successfully used 300 dpi images/non anti-aliased fonts. More specifically, I have used the following convert parameters on a training pdf, which generated a satisfactory image:

convert -density 300 -depth 8 [input].pdf -background white -flatten +matte -compress none -monochrome [output].tif

But then I tried to add a dotted font to Tesseract and it only detected characters properly when I used a 150 dpi image. So, I don't think there's a general solution, it depends on the kind of fonts you're trying to add.

查看更多
登录 后发表回答