OpenCV正样本尺寸? [英] OpenCV positive samples dimensions?

查看:85
本文介绍了OpenCV正样本尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我遇到了很多关于 OpenCV 的 haartraining 和级联训练工具的教程.特别是我对使用 createsamples 工具训练汽车分类器很感兴趣,但是关于 -w 和 -h 参数的说法似乎到处都是相互矛盾的,所以我很困惑.我指的是命令:

So I've come across lots of tutorials about OpenCV's haartraining and cascaded training tools. In particular I'm interested in training a car classifier using the createsamples tool but there seem to be conflicting statements all over the place regarding the -w and -h parameters, so I'm confused. I'm referring to the command:

$ createsamples -info samples.dat -vec samples.vec -w 20 -h 20

我有以下三个问题:

  • 我了解正样本的纵横比应该与您从上面的 -w 和 -h 参数中得到的纵横比相同.但是所有正样本的 -w 和 -h 参数是否也必须相同 size?例如.我有近 1000 张图片.裁剪后是否都必须是相同的尺寸?

  • I understand that the aspect ratio of the positive samples should be the same as the aspect ratio you get from the -w and -h parameters above. But do the -w and -h parameters of ALL of the positive samples have to be the same size, as well? Eg. I have close to 1000 images. Do all of them have to be the same size after cropping?

如果重要的不是大小而是纵横比,那么与 OpenCV 工具中提到的 -w 和 -h 参数相比,正样本的纵横比必须精确匹配多少?我的意思是,分类器是否非常敏感,以至于这里和那里的几个像素都会影响它的性能?或者你会说使用图像是安全的,只要它们在肉眼中的比例大致相同.

If it is not the size but the aspect ratio that matters, then how precisely matching must the aspect ratio be of the positive samples, compared to the -w and -h parameters mentioned in the OpenCV tools? I mean, is the classifier very sensitive, so that even a few pixels off here and there would affect its performance? Or would you say that it's safe to work with images as long as they're all approximately the same ratio by eye.

我已经将几张图片裁剪成相同的尺寸.但是在尝试使它们都具有相同的大小时,其中一些在边界框中包含的背景比其他的要多一些,而另一些的边距略有不同.(例如,请看下面的两张图片.较大的汽车占据了更多的图像,但较小的汽车周围有更宽的边距).我只是想知道拥有这样的图像集合是否很好,或者它是否会降低分类器的准确性,因此我应该确保所有感兴趣的对象(在本例中为汽车)周围的边界框更紧密?

I have already cropped several images to the same size. But in trying to make them all the same size, some of them have a bit more background included in the bounding boxes than others, and some have slightly different margins. (For example, see the two images below. The bigger car takes up more of the image, but there's a wider margin around the smaller car). I'm just wondering if having a collection of images like this is fine, or if it will lower the accuracy of the classifier and that I should therefore ensure tighter bounding boxes around all objects of interest (in this case, cars)?

推荐答案

第一个问题:是的,所有用于训练的图像必须是相同大小的.(至少上次我做人脸检测样本训练.这里应该是一样的.如果我没记错的话,如果图像大小不一样会出错.但是你可以试试看是否有时间许可.)

First Question: Yes, all the images to be used for training have to be the same size. (at least for the last time I did face detection sample training. Should be the same here. If I am not wrong, there will be an error if the images are not of same size. But u can try it out and see if time permits.)

第二个问题:不太确定你在这里问什么.但是分类器并不像你想象的那么敏感.与感兴趣的对象相差几个像素,例如手,如果小指缺少几个像素(由于裁剪),而其他图像的拇指缺少几个像素,等等......分类器仍然是能够检测到手.因此,这里和那里缺少一些像素或添加了一些背景像素,最终不会对分类器产生太大影响.

Second Question: Not really sure what you are asking here. But the classifier is not that sensitive as u think. A few pixels off the object of interest, let's say the hand for instance, if the little finger is missing a few pixels(due to cropping) and other images have few pixels missing for the thumb, etc... the classifier will still be able to detect the hand. So a few pixels missing here and there or a few background pixels added in, will not affect the classifier much at the end of the day.

第三个问题:您应该将图像裁剪为仅包含汽车以获得最大效果.尽量消除背景.我基于嘈杂背景、黑色背景和背景最小的裁剪样本进行了研究.根据我的记忆,具有最小背景的裁剪样本在假阳性和假阴性方面显示出最好的结果.

Third Question: You should crop the image to consist of the car only for maximum result. try eliminate as much background as possible. I did a research based on samples with noisy background, black background and cropped samples with minimum background. Cropped samples with minimum background shows the best results in terms of false positive and false negative, from what I remember.

你可以使用对象标记来做到这一点:http://achuwilson.wordpress.com/2011/02/13/object-detection-using-opencv-using-haartraining/

U can use object marker to do it: http://achuwilson.wordpress.com/2011/02/13/object-detection-using-opencv-using-haartraining/

繁琐的方法是在裁剪后使用绘画将所有图像调整为相同的像素值.

The tedious way would be to use paint to resize all the image to the same pixel value after cropping.

这个链接也应该回答你的问题:http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html

This link should also answer your question: http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html

我也同意 GilLevi 的观点,即与 Haar、HoG、LBP 级联相比,有更好的检测方法.图像的训练可能需要几天时间(取决于训练的图像数量).如果您真的必须使用级联方法并且您希望最大限度地减少培训时间,使用类似 Haar 的特征进行训练比使用 HoG 或 LBP 需要更长的时间.但从结果来看,我不确定哪一种能确保更好的性能和稳健性.

I also agree with GilLevi that there are much better detection methods compared to Haar, HoG, LBP cascade. training of the images can take days(depends on number of images trained). If you really have to use the cascade methods and you are looking to minimise training time, training with Haar-like features takes much longer than with HoG or LBP. But results wise, I am not really sure which will ensure better performance and robustness.

希望我的回答对你有所帮助.如果还有更多问题,请发表评论.

Hope my answer helped you. Should there be more questions, do comment.

这篇关于OpenCV正样本尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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