Please help to get more knowledge on the my first-time haar training results. So I want to train Haar classifier to recognize simple pen, following Dileep Kumar’s article.
Using my cellphone I made 14 pen pictures. These pictures size is big about: 263x2814
Then I collected negative pictures, some of them downloaded from web, with size 640x480, and some of them made using my phone camera, with size: 1920x1080,5313x2388
Some of these negative images are really big. I have total 158 negative images.
After that create negative and positive images list and run the: createsamples command:
perl createtrainsamples.pl positives.dat negatives.dat samples 250 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 0.5 -maxyangle 0.5 maxzangle 0.5 -maxidev 40 -w 160 -h 20"
I am not sure here if 160 for with and 20 for height is okay or not?
And then after having samples.vec file I run the cascade training, using this command:
opencv_traincascade -data firstTry -vec samples.vec -bg negatives.dat -numPos 250 -numNeg 99 -numStages 25 –featureType HAAR -mode ALL -w 160 -h 20 -mem 2048
I used the same width and height, but not sure if this is something right. I took the width and height values from some reference script. After getting the cascade.xml file, I am running the detectMultiScale on my picture using the following argument:
faces = faceCascade.detectMultiScale( image, scaleFactor=1.4, minNeighbors=3, minSize=(30, 30) )
The detection does not work well. It is just detecting some parts of the pen and not the full pen.
Also when I have some photo where pen is put in environment, than pen is not being detected.
I think I need to resize all positive and negative images and make them same size, though not sure on this.
Could you please provide some opinions on what I have done wrong here and how I can improve my results.
You can find all my files here: