Ask Your Question
0

Verify vector file and background file

asked 2013-07-18 02:13:45 -0500

Anshul gravatar image

updated 2013-07-18 05:45:37 -0500

hi

I was trying to train cascade using opencv_traincascade binary, I am using linux 3.7, Below is result of my command

PARAMETERS:
cascadeDirName: imgs/cascade/
vecFileName: imgs/vector.vec
bgFileName: negative.dat
numPos: 200
numNeg: 8
numStages: 10
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: LBP
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.9
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100

===== TRAINING 0-stage =====
<BEGIN
OpenCV Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
) in get, file /home/abuild/rpmbuild/BUILD/OpenCV-2.4.3/apps/traincascade/imagestorage.cpp, line 159
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/abuild/rpmbuild/BUILD/OpenCV-2.4.3/apps/traincascade/imagestorage.cpp:159: error: (-5) Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
 in function get

./cascade_taining.sh: line 38: 11514 Aborted                 opencv_traincascade -data imgs/cascade/ -numPos 200 -numNeg 8 -numStages 10 -featureType LBP -maxFalseAlarmRate 0.9 -w 24 -h 24 -vec imgs/vector.vec -bg negative.dat

I wanted to verify my vector file and background file, I dont know how to do it.

Thanks Anshul

edit retag flag offensive close merge delete

Comments

2

You can open your "negative.dat" file in a text editor. As for verifying a vec file, Use the opencv_createsamples.exe by passing vec file, width and height as arguments and -show option. (For example, opencv_createsamples.exe -vec imgs/vector.vec -w 640 -h 480 -show). But why are you using such high resolution like 640x480? It will take ages to train.

Try following this for a start.

Prasanna gravatar imagePrasanna ( 2013-07-18 02:37:20 -0500 )edit

I read that link, and improved lot of things. but while verifying the vect file by show argument does not work for me, It shows me only first sample, not all sample. if i press esc at the windows no other window appear and program exit. if i press x at right upper corner of window than window close and create sample utilitiy get hang. if this is normal behaviour than i want to see all the sample created and stored in vct file. do you have any clue.

Anshul gravatar imageAnshul ( 2013-07-18 05:22:24 -0500 )edit
1

Theres a waitKey(0) between showing samples from a vec file. Hit the enter key to go ahead. Make sure you merge the vecs created for each image.

Prasanna gravatar imagePrasanna ( 2013-07-18 08:51:46 -0500 )edit
1

Got that ! Why dont you put ur both comment as answer, for me they were answer to my question. Thanks lot

Anshul gravatar imageAnshul ( 2013-07-19 04:21:15 -0500 )edit

Also, when training will start, 640x480 pixel positives will crash your system. The image pyramids are stored in memory (thats how it is implemented) together with all features calculated. This will give an exponential grow in RAM needed, slurp it all up and then create a gigantic swap. Suggested is to use at least a size of a factor 10 smaller (64x48) pixels.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-19 06:25:00 -0500 )edit
1

Hey Steve, Look what happened to your asterisks. Edit it before you confuse others. :D

Prasanna gravatar imagePrasanna ( 2013-07-19 06:47:51 -0500 )edit

Steve and Prasanna

Sorry for too late reply, busy in collecting positive sample.

Actually i was trying with lot of images and there are some image of different dimension. I have 1200 positive samples and in those 1000 are of 1280x720(taken out from my own camera) and 100 are of random size(downloaded from internet google image) so what would be the right choice height and width ???

I don't Know What is wrong, but my cascade still does not detect object well.

Anshul gravatar imageAnshul ( 2013-07-30 05:02:34 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-07-30 05:05:39 -0500

Anshul gravatar image

By Prasanna-

You can open your "negative.dat" file in a text editor. As for verifying a vec file, Use the opencv_createsamples.exe by passing vec file, width and height as arguments and -show option. (For example, opencv_createsamples.exe -vec imgs/vector.vec -w 640 -h 480 -show). But why are you using such high resolution like 640x480? It will take ages to train.

Theres a waitKey(0) between showing samples from a vec file. Hit the enter key to go ahead. Make sure you merge the vecs created for each image.

edit flag offensive delete link more

Comments

Keep your width and heigth ration beneath 100 pixels dimensions. Everything gets stored in memory so it would result in your memory and swap getting overloaded and then your app will crash. I always do it like this, if resolution is 640x480 then I go for 64x48 which is divide by factor 10. Those are already large sizes, the more pixels, the more features it needs to calculate. Knowing that a 24x24 pix image can yield up to 150.000 seperate features, you know you can't take it too big. It will grow exponentially.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-30 06:03:19 -0500 )edit

that was my first day using opencv, to verify that whether i have given the dimension of object properly or not it is better to go with high resolution, but when creating sample for cascade training i go for some small resolution.

Anshul gravatar imageAnshul ( 2013-07-30 06:50:51 -0500 )edit

Processing on high resolution using cascade classifiers is not a good thing. The relevant information will still be there at lower scales, still giving the possibility for a classifier to find objects. High resolutions will yield features that are too specific for detection purposes, leading to overfitting of your algorithm.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-30 06:58:51 -0500 )edit

hi steven

Dont take me negative. I have already posted in your question, that i an training cascade on low resolution (24x24 or 64x32 still dont know exact value)), high resolution was used to test (manually by eyes) that whether the dimension of object(info.txt) in sample are correct or not. just for verifying the vector file

Anshul gravatar imageAnshul ( 2013-07-30 07:20:34 -0500 )edit
-1

answered 2017-11-16 18:15:32 -0500

DrVivek gravatar image

Here is Real solution while creating vector file put as max as positive sample or images you have and while training in traincascade put number of positive less than the your vector file had, general thumb rule put 100 less number of positive while training. trust me ,it not let you down eg. while creating in vector fle positive no. 1000 so while HAAR training put numPos 900

edit flag offensive delete link more

Comments

there is absolutely no reason to revive topics of 2013 ...

StevenPuttemans gravatar imageStevenPuttemans ( 2017-11-17 04:18:08 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-07-18 02:13:45 -0500

Seen: 4,318 times

Last updated: Jul 30 '13