Ask Your Question
0

Can not change width height (-w -h parameter) in opencv_trainingcascade.exe???

asked 2016-06-21 13:13:15 -0600

Bruce gravatar image

Hello all,

I try to use opencv_traincascade.exe to detect my object (rear of car). But i have a problem when i choose size -w -h. This is all af step i do. _ I have positive.txt which have absolute direction to all of image which ha object. _ I have negative.txt which have absolute direction to all of background image. _ Now i use opencv_createsamples.exe to create vector file with command.

D:\Project_Android\Classifier\bin\opencv_createsamples.exe -info positive.txt -vec vector.vec -num 1000 -w 72 -h 48

Which this command, it run and i have vector file which have 1000 positive sample, size 72x48. Now, i use opencv_traincascade.exe to train, i know that size of train image had to equal size of createsample. so my command is:

D:\Project_Android\Classifier\bin\opencv_traincascade.exe -data HaarTraining -vec vector.vec -bg negative.txt -numPos 250 -numNeg 1500 -numStages 10 -nonsym -minhitrate 0.999 -maxfalsealarm 0.5 -mode ALL -w 72 -h 48 -precalcValBufSize 2046 -precalcIdxBufSize 2046 PAUSE

It not run and say error "Assertion failed <_img.row*_img.col==vecSize> in CvCascadeImageReader::PosReader::get, file C:buildslave64\win64_amdoc1\2_4_PackSlave-win6411-shared\opencv\apps\traincascade\imagestorage.cpp, line 149". More error detail is shown in below picture.

image description

In this picture i see, size of image still config width 24 height 24. And one more thing -precalcValBufSize and -precalcIdxBufSize 2046 is stll config defaul value 1024. it seem to be no change with -w -h -precalcIdxBufSize -precalcValBufSize althought i configed it. So i don't know what problem with it. I was change version of opencv 2.4.11, 2.4.12, 3.1, lastest 2.4.13. But no thing happen, It still auto config defaul value for -w -h -precalcIdxBufSize -precalcValBufSize and i can set value for this parameter.

if i use size 24x24 for createsample and haartraining. It's training good, just can use 24x24 , other sizes are still say error like above. So what problem with it and how can i fix it to get new size, i would like to use size 72x48 (i use win 7 64 bit and i was copy bin folder of opencv C:\Users\BAOTRUONG\Desktop\opencv\build\x64\vc11\bin ).

edit retag flag offensive close merge delete

Comments

I never ran into this and am using different width and height parameters for each new project, so it does work ... this is very strange. Could you reduce the amount of traincascade parameters, take everything default except width and height? Like opencv_traincascade.exe -data HaarTraining -vec vector.vec -bg negative.txt -numPos 250 -numNeg 1500 -w 72 -h 48 and report back?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-06-30 07:38:14 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-08-02 10:41:43 -0600

shoemakerlevy9 gravatar image

During training OpenCV will create a params.xml file. I have had the issue where I change -h -w in my command but I didn't delete this params.xml file from my previous session. This caused an error similar to yours. Try checking if you have a params.xml file, and if so delete it and re-train. Mine gets generated in the top level folder where I am running the command.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-21 13:13:15 -0600

Seen: 459 times

Last updated: Jun 21 '16