Ask Your Question
0

Need help on trainCascade usage of mine

asked 2014-02-11 01:20:30 -0600

ART gravatar image

updated 2014-02-11 01:48:28 -0600

Hi All, I am trying to detect the banana using traincascade approach. positive sample-40(40*50 using createsample.exe )

+ive desc file looks like:

rawdata/1.bmp 1 180 154 494 161
rawdata/2.bmp 1 247 154 349 175
rawdata/3.bmp 1 133 118 488 141

Used the CreateSamples utility

createsamples -img Positive\rawdata\2.bmp -num 50 -bg bg.txt -vec data\positive2.vec -maxxangle 1.1 -maxyangle 1.1 -maxzangle 0.5 -maxidev 40 -bgcolor 0 -bgthresh 0 -w 24 -h 24

where i am passing 40 diff single +ive sample and creating 50*40 = 2000 samples

Negative 600 images and -ive desc looks like:

bg.txt :

Negative/1.bmp
Negative/2.bmp
Negative/3.bmp

after that using the mergevector.cpp.

using command

mergevec pos-neg.txt pos-neg.vec -w 24 -h 24

so my pos-neg.vec is having size of 2.19mb.

Utility used for Training

I am using

TrainCascade.exe -data Result -vec pos-neg.vec -bg bg.txt -numPos 1500 -numNeg 600 -w 24 -h 24 -featureType LBP -minHitRate 0.999 -maxFalseAlarmRate 0.5 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024

My console O/p of training:

C:\Banana>TrainCascade.exe -data Result -vec pos-neg.vec -bg bg.txt -numPos 1500 -numNeg 600 -w 24 -h 24 -featureType LBP

PARAMETERS:

cascadeDirName: Result
vecFileName: pos-neg.vec
bgFileName: bg.txt
numPos: 1500
numNeg: 600
numStages: 20
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: LBP
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   1500 : 1500
NEG count : acceptanceRatio    600 : 1
Precalculation time: 1.025
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|    0.998|    0.215|
+----+---------+---------+
END>

OpenCV Error: Unspecified error (Invalid fs.state) in unknown function, file ..\..\..\src\opencv\modules\core\src\persistence.cpp, line 5271

Can Anyone Help me out where I am doing wrong. Any Help is appreciated.

Thank you.

edit retag flag offensive close merge delete

Comments

and when i am using the C:\Banana>TrainCascade.exe -data Result -vec pos-neg.vec -bg bg.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 1000\ -numNeg 600 -w 24 -h 24 -mode ALL -precalcValBufSize 1024\ -precalcIdxBufSize 1024

I am getting :

PARAMETERS: cascadeDirName: Result vecFileName: pos-neg.vec bgFileName: bg.txt numPos: 1000 numNeg: 600 numStages: 20 precalcValBufSize[Mb] : 1024 precalcIdxBufSize[Mb] : 1024 stageType: BOOST featureType: HAAR sampleWidth: 24 sampleHeight: 24 boostType: GAB minHitRate: 0.999 maxFalseAlarmRate: 0.5 weightTrimRate: 0.95 maxDepth: 1 maxWeakCount: 100 mode: ALL

===== TRAINING 0-stage ===== <BEGIN POS count : consumed 1000 : 1000 NEG count : acceptanceRatio 600 : 1 OpenCV Error: Insufficient memory (Failed to allocate 1674252

ART gravatar imageART ( 2014-02-11 02:03:46 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-02-11 03:14:43 -0600

I guess I have multiple remarks that can basically lead to errors in training:

  1. Use only natural occuring training images. Using the utility to apply translations, rotations, ... screws up the performance of your classifier model. So if you have 40 positives, stick to those 40 positives, don't make 2000 of them.
  2. You are making a model of 24x24 pixels while a banana has more a ratio of 24/48 pixels or so, just like a car.
  3. I have completely no idea why you are merging your negatives into the vector. Looking at the official tutorial, there isn't a single merge operation around there...
  4. Your number of positives is way larger than number of negatives... This is weird, since an object will never have as much variations as the possible backgrounds in most cases. It should be like 40 pos and 1000 neg.
  5. Your two cascade trainings contain different parameters. One goes to HAAR wavelets, other one to LBP. Please select one and stick to it.
  6. As your training is running out of memory, what is your system configuration? You are now using more than 2GB of RAM, which is a lot if you have only 3GB available for example. Please close down any unnecessary applications
edit flag offensive delete link more

Comments

Hi Steven, Thanks for your reply.

I have made the vector file using createsample for 40 samples with any distortions. and got the vector file of 91kb.

I have even made the ratio as 24/48 pixel

Took 40 pos and 1000 negative

I'm now using traincascade : without using the featureType i.e, making it as HAAR

When i start the training using :

TrainCascade.exe -data classifier -vec data\posivec.vec -bg bg.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 40 -numNeg 1000 -w 24 -h 48 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024

I got the OpenCV Error: Insufficient memory (Failed to allocate 1073741764 bytes) in unknown function, file ......\src\opencv\modules\core\src\alloc.cpp, line 52

ART gravatar imageART ( 2014-02-11 04:28:27 -0600 )edit

and when i am adding the featureType -LBP

TrainCascade.exe -data classifier -vec data\posivec.vec -bg bg.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 40 -numNeg 1000 -w 24 -h 48 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024 -featureType LBP

I am getting :

OpenCV Error: Unspecified error (Invalid fs.state) in unknown function, file ......\src\opencv\modules\core\src\persistence.cpp, line 5271

I am using Windows7 System with 4gb Ram

ART gravatar imageART ( 2014-02-11 04:33:46 -0600 )edit

This still a memory problem. Give me the configuration details of your system. Also try reducing the precalc buffers to 512 as it is default. See if that works out. Also, please add a / behind the cascade path. I have experienced that the algorithm doesn't work when it is ignored. So change to cascade/

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-11 04:46:51 -0600 )edit

My System Configuration: Intel core 2 Duo with 4gb RAM 64 bit Windows7 operating System.

I have made changes to the bufSize to 512 and even to 256 .

still throwing me : OpenCV Error: Insufficient memory (Failed to allocate 1073750100 bytes) in unknown function, file ......\src\opencv\modules\core\src\alloc.cpp, line 52

ART gravatar imageART ( 2014-02-11 05:05:10 -0600 )edit

can you downgrade the number of negatives to 500?

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-11 07:11:05 -0600 )edit

for the command: TrainCascade.exe -data classifier/ -vec data\posivec.vec -bg bg.txt -numStages 20 -minHitRate 0.1 -maxFalseAlarmRate 0.1 -numPos 30 -numNeg 500 -w 24 -h 48 -mode ALL -precalcValBufSize 64 -precalcIdxBufSize 64

It is Throwing OpenCV Error: Unspecified error (Invalid fs.state) in unknown function, file ......\src\opencv\modules\core\src\persistence.cpp, line 5271

and when i change the buf size to 512 for 500 Negatives it is still throwing Insufficient Memory.

ART gravatar imageART ( 2014-02-11 08:14:41 -0600 )edit

Okay so the memory issue seems to be your computer not able to reserve more memory for the application. Did you limit it somewhere? As for the other error, never came accross it... However the -vec needs front slashes!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-11 08:20:34 -0600 )edit

Nope ,i didnt make any limits to the memory .

ART gravatar imageART ( 2014-02-11 08:39:04 -0600 )edit

Hi steven, What could be the reason for the opencv error persistence.cpp. I am not getting any info about that . and thanks for ur suggestions.

ART gravatar imageART ( 2014-02-12 05:05:56 -0600 )edit

As I said, I never came across it so I have basically no idea, nor the time for the moment to investigate it any deeper.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-12 07:05:26 -0600 )edit

Question Tools

Stats

Asked: 2014-02-11 01:20:30 -0600

Seen: 1,953 times

Last updated: Feb 11 '14