opencvclassificationcascade-classifier

OpenCV Cascade Classifier Training


I refer this tutorial and this file to train my own classifier. But I faced a few of question.

  1. I used objectmarker.exe to generate the info.txt. In info.txt, each record has different width and height but both of them keep ratio in rectangular. So, what should I set the value of width and height argument in the 02 haarTraining.bat?

  2. The width and height of negative sample should also follow positive sample?

Updated 20/06/2017

For example, I used objectmarker.exe to mark down the following 2 image (The marked area represent as the green rectangle). However, these 2 rectangle width and height are not the same.

In info.txt:

rawdata/IMG_20170616_170411.jpg 1 993 424 201 284 
rawdata/IMG_20170616_170544.jpg 1 895 994 69 95 

Therefore, I don't know how to config the width and height argument in the 02 haarTraining.bat.

enter image description hereenter image description here


Solution

    1. so the aspect ratio of your positive marked samples is fixed? Choose the minimum size of objects you still want to detect, but big enough to have all necessary features (so maybe you have to train multiple times and choose the best one - was done in the original face detection paper this way).

    2. negative samples just are not allowed to contain the target objects, the size doesn't matter, each (resized) image (sub-)window in each negative sample will be used as a negative sample.

    For example if you want to detect cats of sample size 28x24 in the image, you can provide a 8000x6000 street view image without any cats in it, which will automatically provide a huge amount of negative samples of size 28x24 to the training.