MATLAB Answers

Error generating samples for cascade classifier training

14 views (last 30 days)
While trying to run trainCascadeObjectDetector with MATLAB R2013a on Windows, I keep getting an error that won't allow me to get past the very first stage.
I have been following MATLAB's tutorial on how to "Train a Cascade Object Detector", as well as this blog post .
I am using 4,372 .pgm positive images and 14,440 .pgm negative images.
The positive images are given to the function as a structure variable which contains path+filename and object bounding box of the images. Both positive and negative images are located in their respective subfolders.
Calling of the function:
negativeFolder = ('./negativeFolder');
trainCascadeObjectDetector('trainedCrater1.xml',positiveData,negativeFolder);
The following is printed when the training starts:
Automatically setting ObjectTrainingSize to [ 32, 32 ]
Using at most 3992 of 4372 positive samples per stage
Using at most 7984 negative samples per stage
Training stage 1 of 20
The error that I am getting is this:
Training stage 1 of 20
[....................................................Error using ocvTrainCascade
Error in generating samples for training. No samples could be generated for training the first cascade stage.
Error in trainCascadeObjectDetector (line 265)
ocvTrainCascade(filenameParams, trainerParams, cascadeParams, boostParams, ...
Error in training (line 24)
trainCascadeObjectDetector('trainedCrater1.xml',positiveData,negativeFolder);
Does anyone have any kind of suggestion on how to fix this issue? Thank you very much!

  0 Comments

Sign in to comment.

Accepted Answer

Dima Lisin
Dima Lisin on 12 Jun 2015
Hi Ferran,
Essentially, this error means that the first stage of your classifier has a very high false negative rate. In other words, it classifies most positive samples as negatives. It sounds like something may be wrong with your data. Can you please post some sample positive and negative images? What kind of objects are you trying to detect?

  5 Comments

Show 2 older comments
Ferran Martinez
Ferran Martinez on 15 Jun 2015
Hello Dima,
Thank you so much for all the suggestions! I'll try these variations.
ronny3050
ronny3050 on 16 Jul 2015
Hi Ferran,
I was just wondering if you figured out a solution for the problem. I am stuck with the same situation. I have around 277 positive samples, however, all are very alike. My guess is that the classifier is failing because the positive samples are so alike that it cannot find addition features. I might be wrong, so I am wondering what you did to fix it.
Thank you so much. - Deb
Eric
Eric on 30 Aug 2016
Hi Ferran,
I was trying to train the cascade object detector in order to detect mouth region in the face. I was doing so because the built-in code that I've found on the internet was detecting eyebrow or nostrils as mouths in some of the test images. I have 30 positive images with ROIs and 10 negatives (without ROIs). When I started training the Viola-Jones classifier by trainCascadeObjectDetector function, I faced the same problem. Could you please tell me the solution? I hope you’ve found out the solution already.
Thank you -Eric.

Sign in to comment.

More Answers (1)

Zhenglin Wang
Zhenglin Wang on 8 Jun 2017
Might be because training images are smaller than 32x32. Try to specify such as " 'ObjectTrainingSize', [28 28]"

  1 Comment

Hossam Alzomor
Hossam Alzomor on 30 Jul 2019
what is the problem with small images?
I am facing the same problem, my images are 32*32
I have 106 ROI images and 96 NROI images
but the false -ve detection is 90%

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!