简体   繁体   中英

OpenCV Traincascade returns garbage

I am attempting to train a cascade classifier to detect deer in images. The problem is that my classifier always returns exactly one positive hit, in the direct center of the input image. This is true for a test image, a training image from the positive set, and a training image from the negative set.

For my positive training set, I am using the deer image set from the CIFAR-10 dataset ( http://www.cs.toronto.edu/~kriz/cifar.html ). This gives me 5000 32x32 color images of deer in various poses. For the negative training set, I am using the images from the Labelme12-50k dataset ( http://www.ais.uni-bonn.de/download/datasets.html ), which gives me 39000 random images. I resized all of these images to 32x32 to make the sizes consistent with the positive training set.

I then created the positive vector with the following command:

./opencv_createsamples -info posFiles.txt -w 32 -h 32 -num 5000 -vec posVector.vec

The vector appeared to be created successfully. Then, I trained my cascade classifier using the command:

./opencv_traincascade -data /home/mitchell/ece492/Deerinator_Software/Deerinator_Software/trunk/Haar/data -vec posVector_5000.vec -bg negFiles.txt -numPos 4000 -numNeg 39000 -w 32 -h 32 -featureType LBP -numStages 18

The cascade classifier takes about 5 hours to train, and appears to have a negative rejection rate of 0.038 However, whenever I test the classifier on an image using the command:

./c-example-facedect --cascade=cascade.xml img.png

I always get the same result: a single hit in the center of the image. This happens for testing images, images from the positive training set, and images from the negative training set. I'm not sure what to do at this point - at this point, I'm just using the opencv sample executables. I'm not sure if the process is with my input training set or with my usage of the classifier. Anyone have any suggestions?

I think this fails because the picture samples are too small. I think they are just 32 by 32. How can that be used for positive samples? If I am wrong and the pictures are actually bigger, then teach me how to unpack them and I bet I can get this to run for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM