1

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

SinLok
  • 589
  • 1
  • 5
  • 19
  • didn't watch the video completely, but it looks like they've chosen ALL positive samples as numPos, which is not so well! You'll lose some positive samples in each stage, so there should be more positive samples than numPos. – Micka Jun 19 '17 at 18:03
  • I don't understand why positive samples > numPos. numPos is used to tell haartraining.exe how many samples are used for training. Therefore, the value of numPos should be equal to the number of positive samples. Am I wrong? – SinLok Jun 20 '17 at 00:29
  • numPos is the number of positive samples per stage! If your minHitrate is < 1 (which should be), you'll lose some positive samples in each stage. – Micka Jun 20 '17 at 04:09
  • https://stackoverflow.com/questions/44337461/can-numpos-be-a-negative-number-in-haar-cascade-training/44343398#44343398 – Micka Jun 20 '17 at 04:13

1 Answers1

1
  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.

Micka
  • 19,585
  • 4
  • 56
  • 74
  • The aspect ratio is not fixed. I updated a example, could you give me some suggestion? – SinLok Jun 20 '17 at 00:22
  • you'll have to fix the aspect ratio and adjust the marked regions (e.g. add some background) to fit the aspect ratio. However, if it is ok for you to distort the objects a little bit (e.g. the aspect ratio is "nearly" fixed), then it might be ok for you that the marked objects are resized. To choose a sample size you could use the average/median aspect ratio. – Micka Jun 20 '17 at 08:44