Problems with traincascade

asked 2015-10-20 13:05:45 -0500

updated 2015-10-20 13:12:10 -0500

berak gravatar image

Yeah, I have also got many emails from people regarding the same stuff but till now I have not faced such issue. I have also developed an Haar Classifier using 3000+ positive images and 1500+ negative images. It took me almost 1 week to make a strong classifier.

I would like to recommend one thing. Please check the input parameters mentioned in the batch files of Haar Training. The input parameters must match ( e.g. the window size height and width, number of positive and negatives should be same)

Please check the prerequisites mentioned below for Haar Training:

  1. Number of Positives & Negatives Images: The number of positive images and negatives images must match with the input given to the HaarTraining.dat.

    For example: npos 1595 -nneg 2270 -nstages 20 -mem 1024 -mode ALL -w 25 -h 25

  2. Samples Creation : Please recheck that the number of positives and negatives are same and the width and height you mentioned for the object (Bounding box) -num 1595 -w 25 -h 25

    1. Cascade batch file: Please recheck that the input parameters for height and width are same 25 25

---In OpenCV@xxxxxxxxxxxxxxx, <opencv@xxxxxxxxxxxxxxx> wrote:

 In the past few days I've been investigating the createsamples and traincascade methods in order to generate a car cascaded classifier. Such as myself, many people find themselves not having a clue about how to get past all the errors and problems, so in this post I'll explain my procedure and reasoning as well as I can, as well as my problem.
 To give a little more context, in the past I implemented myself a boosted classifier with Haar features but since the method was not cascaded it was very slow. I am, however, very well acquainted with the method behind the cascaded classification.
 Problem: Car classification on images
 I downloaded a dataset (set of images) that provides 550 positive windows (100w x 40h images with cars) and 500 negative windows (100w x 40h images without cars), and I intend to use this data to train the cascaded classifier.
 STEP 1 - Generate the .dat files for creating samples
 The createsamples application needs a .dat file with the information about the positive and negative samples. I generated two .dat files, one with positive windows and other with negative windows:
 positive.dat example structure:
 CarData\TrainImages\POS\pos-0.pgm 1 0 0 100 40
 CarData\TrainImages\POS\pos-1.pgm 1 0 0 100 40 (and more 548 lines of this)
 The number 1 indicates that there is one object in the entire image, and the next 4 integers represent the bounding box that has the object (the entire image in this example)
 negative.dat example structure:
 CarData\TrainImages\NEG\neg-0.pgm
 CarData\TrainImages\NEG\neg-1.pgm(and more 498 lines of this)
 STEP 2 - Generate .vec files
 To do this I use the createsamples.exe application with the following command line:
 : createsamples.exe -info path/positive.dat -vec samples.vec -bg negative.dat -w 100 -h 40 -num 550 ...
(more)
edit retag flag offensive close merge delete

Comments

There is no problem with the actual cascade training software, there is however a problem with the misconception of parameters. By now this forum is flooded with my answers on this matter, some reaching over 2k views, so I guess people still suffer from it. But by the end of October, all my findings are published in an OpenCV book: https://www.packtpub.com/application-...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-21 09:24:39 -0500 )edit