opencv_traincascade Parameters explanation, image sizes etc
Hello guys, I am trying a long time now to train a descent classifier and to be able to get reliable results from an object detect script. I was trying to follow this tutorial: http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html (which by the way was very helpful). But during the process a lot of questions was born. I will try to ask all of them now and I think the answers will help a lot of people not just me.
Negatives positive images:
a. How many negatives and positive images should I have?
b. Should positives be more than negatives? If yes what is the best proportion between negatives and positives?
c. Is there a preferable format for the pictures (bmp, jpg, png etc)?
d. What should be the size of negative pictures and what should be the size of positive images? Lets say my negative images are 640x320, and the "to be detected" object is 100x50. In negatives folder the images should all be 640x320?In positives folder should be 640x320 cropped images with visible on the object?Or should i place in positives folder images of 100x50 with the object only?
e. Cropping positives images should be clear everything from background? Or should I use just rectangle around object, including some of the surrounding background?
f. I tried to use the "famous" imageclipper program, with no luck. Does anyone done it? Is there any walk through tutorial to install this program?
g. Opencv_createsamples: Is it necessary? How many samples should I use? About -w and -h I read a lot of tutorials on line that their saying that this should be proportional to real images. So all of my positive images should have exactly the same size? If my positive images are 100x50 and if i use as paramters -w 50 -h 25, images will be cropped or decrease? This is going to affect the training and finally the detection procedure?
opencv_traincascade: Below are all the parameters:
-vec <vec_file_name>
-bg <background_file_name>
[-numPos <number_of_positive_samples =="" 2000="">]
[-numNeg <number_of_negative_samples =="" 1000="">]
[-numStages <number_of_stages =="" 20="">]
[-precalcValBufSize <precalculated_vals_buffer_size_in_mb =="" 256="">]
[-precalcIdxBufSize <precalculated_idxs_buffer_size_in_mb =="" 256="">]
[-baseFormatSave]
--cascadeParams--
[-stageType <boost(default)>]< p="">
[-featureType <{HAAR(default), LBP, HOG}>]
[-w <samplewidth =="" 24="">]
[-h <sampleheight =="" 24="">]
--boostParams--
[-bt <{DAB, RAB, LB, GAB(default)}>]
[-minHitRate <min_hit_rate> = 0.995>]
[-maxFalseAlarmRate <max_false_alarm_rate =="" 0.5="">]
[-weightTrimRate <weight_trim_rate =="" 0.95="">]
[-maxDepth <max_depth_of_weak_tree =="" 1="">]
[-maxWeakCount <max_weak_tree_count =="" 100="">]
--haarFeatureParams--
[-mode <basic(default) |="" core="" |="" all<="" p="">
--lbpFeatureParams--
--HOGFeatureParams--
Can anyone explain all of these, what are they doing, how can affect the training and the detection.
Training:
During training i am getting those: ===== TRAINING 0-stage =====
POS count : consumed 400 : 400 NEG count : acceptanceRatio 1444 : 1 Precalculation time: 12 +----+---------+---------+ | N | HR | FA | +----+---------+---------+ | 1| 1| 1| +----+---------+---------+ | 2| 1| 1| +----+---------+---------+ | 3| 1| 0.454986| +----+---------+---------+
Training until now has taken 0 days 0 hours 20 minutes 11 seconds.
Can anyone explain that table and all the other information?
- After training. I have trained my classifier for 5 stages, and was able to find some objects on image (with a lot ...
I think you should start with the search button on train cascade, classifier training, parameters and so on ... this topic has been discussed about a 1000 times with nice and long explanations (including from myself). There is no use in repeating it over and over again...
Some usefull links:
And start reading the results of this search query. Once you have read everything, which will take you up to an hour of 3, you will fully grasp everything.
@tomnjerry, are you the topic starter? If so it is somewhat unclear to me what you edited and what questions still stand. Can you please provide a clear update in comments?
Just a few minor edits. Few sentences in the problem were not clear which made question obscure. Also at few places, the words were incorrect. Instance, at 1. Negatives positive images: b. Should negatives be more than negatives? If yes what is the best proportion between it and negative? Such minor changes were made. No changes in problem statement!
Did you read the links I provided? I will get back to this later today with some explanations.