Ask Your Question

Revision history [back]

Problems with traincascade

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 So far so good, the samples.vec file is generated with no issue. STEP 3 - Train the cascaded classifier To do this I use the traincascade application with the following command line: : traincascade.exe -data CarDetector -vec path/samples.vec -bg path/negative.dat -numStages 15 -stageType BOOST -featureType HAAR -w 100 -h 40 -bt DAB -maxDepth 2 -mode ALL PARAMETERS EXPLAINED: numStages(15): means that I want my classifier will have 15 decision stages. stageType(BOOST): each stage is a boosted classifier featureType(HAAR): use haar features for classification. HOG and LBP also available. w(100): detection window width h(40): detection window height bt(DAB): means I want to use Discrete Adaboost (rather than logitboost and others) maxDepth(2): means each weak classifier will use 3 features for classification -mode(ALL): I think it means it will use all variety of haar features. ERROR When I run the command, the program crashes immediately with no error message, so I am completely clueless as to what I am doing wrong. I'm hoping that someone experienced in this matter will identify the problem with my procedure, as this is an issue shared by many people who are trying to use this application.

Problems with traincascade

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 So far so good, the samples.vec file is generated with no issue. STEP 3 - Train the cascaded classifier To do this I use the traincascade application with the following command line: : traincascade.exe -data CarDetector -vec path/samples.vec -bg path/negative.dat -numStages 15 -stageType BOOST -featureType HAAR -w 100 -h 40 -bt DAB -maxDepth 2 -mode ALL PARAMETERS EXPLAINED: numStages(15): means that I want my classifier will have 15 decision stages. stageType(BOOST): each stage is a boosted classifier featureType(HAAR): use haar features for classification. HOG and LBP also available. w(100): detection window width h(40): detection window height bt(DAB): means I want to use Discrete Adaboost (rather than logitboost and others) maxDepth(2): means each weak classifier will use 3 features for classification -mode(ALL): I think it means it will use all variety of haar features. ERROR When I run the command, the program crashes immediately with no error message, so I am completely clueless as to what I am doing wrong. I'm hoping that someone experienced in this matter will identify the problem with my procedure, as this is an issue shared by many people who are trying to use this application.

click to hide/show revision 3
No.3 Revision

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

berak gravatar image

Problems with traincascade

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
 So far so good, the samples.vec file is generated with no issue.
 STEP 3 - Train the cascaded classifier
 To do this I use the traincascade application with the following command line:
 : traincascade.exe -data CarDetector -vec path/samples.vec -bg path/negative.dat -numStages 15 -stageType BOOST -featureType HAAR -w 100 -h 40 -bt DAB -maxDepth 2 -mode ALL
 PARAMETERS EXPLAINED:
 numStages(15): means that I want my classifier will have 15 decision stages.
 stageType(BOOST): each stage is a boosted classifier
 featureType(HAAR): use haar features for classification. HOG and LBP also available.
 w(100): detection window width
 h(40): detection window height
 bt(DAB): means I want to use Discrete Adaboost (rather than logitboost and others)
 maxDepth(2): means each weak classifier will use 3 features for classification
 -mode(ALL): I think it means it will use all variety of haar features.
 ERROR
 When I run the command, the program crashes immediately with no error message, so I am completely clueless as to what I am doing wrong. I'm hoping that someone experienced in this matter will identify the problem with my procedure, as this is an issue shared by many people who are trying to use this application.

application.