为Haar级联生成良好的训练数据 [英] Generating good training data for haar cascades

查看:83
本文介绍了为Haar级联生成良好的训练数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建haar级联,以执行特定字体的OCR;每个字符一个分类器.

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.

所以,有几个问题:

  • 训练算法是否识别出我不关心透明像素?还是如果我将字符叠加在不同的背景上,效果会更好吗?
  • 我应该包含在每个字符上显示不同前缀和后缀的图像,还是应该单独对待每个字符?
  • 我应该包括按比例缩放字符的图像吗?我收集的算法几乎忽略了大小,反而将所有内容按比例缩小以提高效率?

谢谢!

推荐答案

训练算法是否识别出我不关心透明像素?或者,如果我将字符叠加在不同的背景上,效果会更好吗?

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?

如果您要检测单个字母,请单独训练.如果您训练它来检测"ABC",而您只想要"A",那么它将开始收到混合消息.只需训练每个字母"A","B"等,然后您的探测器就应该能够在较大的图像中挑选出每个字母.

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?

我不认为这是正确的. AFAIK HAAR算法无法按比例缩小训练有素的图像.因此,如果您以50x50的字母训练所有图像,但是图像中的字母是25x25,则您将无法检测到它们.但是,如果您训练并检测到相反的方向,您将获得结果.从小处着手,让算法为您更改大小.

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.

这篇关于为Haar级联生成良好的训练数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆