traincascade: object detection size.
I have trained a cascade using LBP to detect certain object. I have trained the cascade using 400 positive images of objects having same size (100 X 40).
To train cascade, I used following command : opencv_traincascade -data data -vec object.vec -bg bg.txt -numPos 400 -numNeg 500 -numStages 14 -w 50 -h 20 -featureType LBP -maxFalseAlarmRate 0.4 -minHitRate 0.99 -precalcValBufSize 2048 -precalcIdxBufSize 2048
Now when I use this cascade on test images, will it detect objects only if they are of the size for which they are trained for or they can detect bigger objects too ? I tried using images (500 X 500) with object being more than (100 X 40) and it cannot detect objects in them.
verify that the xml file is loaded; verify that the test images really have the object; verify the positive images you trained on are containing just the object, and not too much background (I mean that the object you want to detect is not small in some corner, but is the main object in the image); but 400 positives in LPB are going to create a lot of false positives. Your cascade is returning just object of size you trained on and larger.
With parameters
-w 50 -h 20
you will be able to detect objects as small as those dimensions, finding larger object should work perfectly if you do not limit the scale ranges. Can you place your exact detection command? Smaller objects than 50x20 should not be detected however!That is your training command, I want to know with what parameters you are calling your detection function in
detectMultiScale
inside the C++ code. Your model is trained with the window size you specify, BUT at detection time a image pyramid is generated with a sliding window so that other sizes are detected also. To understand that, read the Viola and Jones paper!Detection command:
object_detect.detectMultiScale(grayImage, object, 1.1, 10, CV_HAAR_SCALE_IMAGE | CV_HAAR_DO_CANNY_PRUNING, cvSize(0,0), cvSize(5000 , 5000));
Also can cascade take care of differently oriented objects. For eg: Say I have 500 images of car of which some face towards right and other face towards left. If I train the cascade for this positive image dataset, will it be able to recognize car with either orientation ?