3

I'm trying to train a cascade classifier by the built-in Matlab function "trainCascadeObjectDetector", but that always shows the following error message when I call this function:

trainCascadeObjectDetector('MCsDetector.xml',positiveInstances(1:5000,:),'./negativeSubFolder/',...
'FalseAlarmRate',0.01,'NumCascadeStages',5, 'FeatureType', 'LBP');

Automatically setting ObjectTrainingSize to [ 32, 32 ]
Using at most 980 of 1000 positive samples per stage
Using at most 1960 negative samples per stage

265 ocvTrainCascade(filenameParams, trainerParams, cascadeParams, boostParams, ...
Training stage 1 of 5
[....................................................Time to train stage 1: 12 seconds

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

The number of samples are 5000 positive images and 11000 negative images. The Matlab version is 2014a that is running on Ubuntu 12.04.

I am not sure if I need to increase more training data, because the error message is:

Error in generating samples for training. No samples could be generated for training the first cascade stage.

Could you please have a look at this? Thanks!

Dima
  • 38,860
  • 14
  • 75
  • 115
Zhi Lu
  • 527
  • 5
  • 22

1 Answers1

1

First of all, what is the data type of positiveInstances? It should be a 1D array of structs with two fields: imageFileName and objectBoundingBoxes. positiveInstances(1:5000,:) looks a bit suspicious, because you are treating it as a 2D matrix.

The second thing to check is the negativeSubFolder. It should contain a lot of images without the objects of interest to be able to generate 1960 negative samples per stage.

For future reference, there is a tutorial in the MATLAB documentation.

Dima
  • 38,860
  • 14
  • 75
  • 115