Generating good training data for haar cascades

蹲街弑〆低调 提交于 2019-11-27 16:49:24

问题


I am trying to build haar cascades for doing OCR of a specific font; one classifier per character.

I can generate tons of training data just by drawing the font onto images. So, the plan is to generate positive training data for each character, and use the examples of other characters as negative training data.

I am wondering how much variation I should put into the training data. Normally I'd just try everything, but I gather these things take days to train (for each character!) so some advice would be good.

So, a few questions:

  • Does the training algorithm recognise that I don't care about transparent pixels? Or will it perform better if I superimpose the characters over different backgrounds?
  • Should I include images where each character is shown with different prefixes and suffixes, or should I just treat each character individually?
  • Should I include images where the character is scaled up and down? I gather the algorithm pretty much ignores size, and scales everything down for efficiency anyway?

Thanks!


回答1:


Does the training algorithm recognise that I don't care about transparent pixels? Or will it perform better if I superimpose the characters over different backgrounds?

The more "noise" you give your images on the parts of the training data then the more robust it will be, but yes the longer it will take to train. This is however where your negative sampels will come into action. If you have as many negative training samples as possible with as many ranges as possible then you will create more robust detectors. THat being said, if you have a particular use case in mind then I would suggest skewing your training sets slightly to match that, it will be less robust but much better in your application.

Should I include images where each character is shown with different prefixes and suffixes, or should I just treat each character individually?

If you want to detect individual letters, then train individually. If you train it to detect "ABC" and you only want "A" then it is going to start getting mixed messages. Simply train each letter "A", "B" etc and then your detector should be able to pick out each individual letter in larger images.

Should I include images where the character is scaled up and down? I gather the algorithm pretty much ignores size, and scales everything down for efficiency anyway?

I don't believe this is correct. AFAIK the HAAR algorithm cannot scale down a trained image. So if you train all your images on 50x50 letters but the letters in your images are 25x25 then you won't detect them. If you train and detect the other way round however you will get results. Start small, let the algorithm change the size (up) for you.



来源:https://stackoverflow.com/questions/29022481/generating-good-training-data-for-haar-cascades

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!