Problem in training HAAR classifier

asked 2014-04-18 03:53:38 -0600

Loam gravatar image

updated 2014-04-18 03:58:05 -0600

When i try to start classifier training after about 1 minute i got this:

opencv_traincascaded.exe -data classifier -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 600 -numNeg 900 -w 40 -h 90 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024

This generates the following output

PARAMETERS:
cascadeDirName: classifier
vecFileName: samples.vec
bgFileName: negatives.txt
numPos: 600
numNeg: 900
numStages: 20
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
stageType: BOOST
featureType: HAAR
sampleWidth: 40
sampleHeight: 90
boostType: GAB
minHitRate: 0.999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: ALL

===== TRAINING 0-stage =====

<BEGIN
POS count : consumed   600 : 600
NEG count : acceptanceRatio    900 : 1
Precalculation time: 90.112
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+

OpenCV Error:

Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] && (unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1<< 3) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file C:\OPENCV\opencv-master\modules\core\include\opencv2/core/mat.inl.hpp, line 845

Interesting thing is that if I use this option:

-featureType LBP

then training works fine. I am trying to create a classifier for detecting cars top view. This training I started just for example, and if it will begun to work I will find more positive images to create good classifier. I used 73 positives and with help of createsamples.exe I created 600 samples (73 vec files) and merged them to create one samples.vec (4 Mb). All negative images I used are greyscale, I took them from base of negative images wich was used to create face recognizing classifier and sorted them out deleting any images with cars.

P. S. Sorry for my bad english :)

edit retag flag offensive close merge delete

Comments

1

Start by adding a / to your path of the data! Secondly, I think your data vector is containing wrong information! How do you combine the 72 vector files together?

StevenPuttemans gravatar imageStevenPuttemans ( 2014-04-18 04:03:50 -0600 )edit

@StevenPuttemans I used mergevec.exe to combine them with cmd options:

mergevec.exe "C:\OPENCV\bin\Debug\samples.txt" samples.vec

Loam gravatar imageLoam ( 2014-04-18 04:10:39 -0600 )edit

I am wondering where you got that from, the mergevec isn't an official tool part of the opencv package ...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-04-18 04:21:54 -0600 )edit

@StevenPuttemans I found it here: link text So, what do you advise me to use with this purpose?

Loam gravatar imageLoam ( 2014-04-18 04:27:21 -0600 )edit