Ask Your Question
0

opencv train classifier never contiueus 3 stage

asked 2015-03-04 03:28:54 -0600

I am trying to learn the cascade classifier to learn license plates. I'm running OpenCV 2.4.9 on a Windows 7 server with 16 GB RAM and i7 processor of 3,4 GHz. I want to train the classifier, but it never continuous stage 3.

This is how I made my .vec file on the xxxx there is personal information:

D:\xxxx\trainingBinairImages\build\x64\vc12\bin\opencv_createsamples.exe -info D:\xxxx\trainingBinairImages\positiveNew.dat -bg D:\xxxx\trainingBinairImages\NegativeNew.bg -vec D:\xxxx\trainingBinairImages\output_vec.vec -maxxangle 0 -maxyangle 0 -maxzangle 0 -w 140 -h 40 -num 3311

pause

Parameters:

D:\xxxx\trainingBinairImages\build\x64\vc12\bin\opencv_traincascade.exe -data D:\xxxx\trainingBinairImages\result -vec output_vec.vec -bg negativeNew.bg -numPos 2980 -numNeg 3311 -miniHitRate 0.995 -maxFalseAlarmRate 0.5 -w 140 -h 40 -featureType HAAR -precalcValBufSize 2048 -precalcIdxBufSize 2048
pause

From cmd:

 ===== TRAINING 3-stage =====
<BEGIN
POS count : consumed   2980 : 2981
Train dataset for temp stage can not be filled. Branch training terminated.

If needed to get a look in the files I will edit the extra's. I tried to change the positive and negative values the numStages. Change the directory paths etc. Online there are question about this, that I tried without a solved solutions.

edit retag flag offensive close merge delete

Comments

@StevenPuttemans This is my question

martijnvwezel gravatar imagemartijnvwezel ( 2015-03-04 03:30:37 -0600 )edit

1 answer

Sort by » oldest newest most voted
3

answered 2015-03-04 03:39:30 -0600

Hello Martijn,

Basically the line of code triggering your error is this one. It means that after training each stage of weak classifiers your training algorithm has to update his training set with new data for the following stage.

As you can see in that function you have two parts in that, grabbing positive windows and grabbing negative windows. Since you have the POS count : consumed 2980 : 2981 printed, I am sure the positive window grabbing worked. However this line of code breaks the grabbing once no new negative windows have been found. So that is actually your problem.

So please provide the following information

  1. How did you collect your negative images, what is their size, how many do you have?
  2. -numNeg 3311 how did you define that number?
  3. Could you check what output was generated at stage 0 1 and 2 for pos and neg window grabbing?

Also, I must urge you NOT to use the createsamples utility to perform those rotation, translation and skewing deformations. Instead collect a large set of actual training samples, instead of creating these artificial ones. Your approach will yield not such a good results in real life applications.

edit flag offensive delete link more

Comments

I have data from the Dutch, Belgium and other countries section controls. I have data files with the correct position about the license plates. So I made a python program that crop out the correct license plate by a size of w 140 and h 40. To make the negatives I use the same program only add a random value (in a certain area). Yesterday I found out that in my data where 10 wrong sizes that I deleted. I checked if every image has the same size and there are now. After this I change all the files for training. I have 3309 positive pictures and 3297 negative files. I define –numNeg 3297. So I did not use createsamples utility for the rotations, translation and skewing deformations. My link to the screenshot of the training https://www.dropbox.com/s/6m0i5fzet3q...

martijnvwezel gravatar imagemartijnvwezel ( 2015-03-04 04:21:20 -0600 )edit
1

Hmm that is your problem. You need to supply larger images as negative instead of cropped windows. Imagine that you will need a lot of windows! Each negative window that is classified correctly by the previous stages cannot be used again for the new stage. So most people just supply tons of not object images, the software will do its own job of cutting out the negatives randomly for you. Also the command used on dropbox is NOT the same as the one in the opening topic ...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-04 04:33:56 -0600 )edit
1

I know if I wanted to show you the picture with correct positives and negatives you have to wait 3,5 day. Can the negatives have other sizes. If I use the original negative images and add a gray rectangle on the number plate will this solving my problem?

martijnvwezel gravatar imagemartijnvwezel ( 2015-03-04 04:55:03 -0600 )edit

That is exactly what I am doing :)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-04 06:12:59 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-03-04 03:28:54 -0600

Seen: 717 times

Last updated: Mar 04 '15