6

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

I have the following three questions:

  • 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?

  • 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)?

big car small car

4

1 回答 1

4

第一个问题:是的,所有用于训练的图像都必须是相同的大小。(至少上次我做人脸检测样本训练。这里应该是一样的许可。)

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

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

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

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

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

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

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

于 2014-01-24T03:52:14.583 回答