Ask Your Question
0

cat detection

asked 2014-03-05 11:51:43 -0600

Fr3@k gravatar image

Hi there,

i am trying to build a cascade classifier to identify my cat (used with a cat flap). So the goal is just to identify ONE cat.

I have made 10 images of my cat and builded altogether 200 positives with

./opencv_createsamples -img positives/yuki01.jpg -vec samples/yuki01.vec -w 50 -h 50 -num 20

and

./mergevec samples/info.dat samples/yuki.vec

The vec-File is fine, it contains 200 images. Furthermore I have got 1000 negative images (size 640x480) for the training. I started the classification like this:

./opencv_traincascade -data results -vec samples/yuki.vec -bg negatives/info.dat -w 50 -h 50 -numPos 200 -numNeg 1000

After 16 Stages and a long Time I finally got the cascade.xml file. I used the source code from an OpenCV Tutorial I found here: CascadeClassifier

Of course I changed the cascade name into "cascade.xml". When I start the detection it finds nothing, even if I point the camera directly to the positive images. Feature Type was HAAR but I also tried LBP and its the same result.

Any idea what went wrong? Thanks!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
4

answered 2014-03-05 12:02:51 -0600

updated 2014-03-05 12:04:48 -0600

Createsamples utility will distort and rotate real positive samples to create new samples. This might work with rigid objects like logos, but will fail when the object is complex such as a cat. What you need to do is to record a video of your cat and after one minute you will have 1800 positive samples of it (assuming camera recording at 30 FPS), and then you use that data to train your classifier.

Furthermore, I am not sure if I understood correctly what you said, but do you really want a Haar detector that will single out your cat from cats that are not yours? If this is it, then it wont work. What will happen is that all kinds of cats are going to be detected, as well as some cat-like creatures, such as dogs, and there are always the random false positves. Haar Cascades are cool, but there are no miracles.

Good luck

edit flag offensive delete link more

Comments

So you mean that it is necessary to use about 1800 different positive images?

I want to single out my cat from others, thats right. Though others means about three or four cats. Is there a greater chance to succeed with LBP instead of Haar-Features? I only tried LBP with the positive images described above. Thanks for your help!

Fr3@k gravatar imageFr3@k ( 2014-03-10 14:47:47 -0600 )edit

What I meant was that for a complex detection problem you need thousands of positive and negative samples, not hundreds. I am pretty that Haar Cascade will not work for your problem.. Haar Features are not descriptive enough to single out specific cats from others. You could try to use the other cats images as negative examples... but still I am almost sure it will not work. Good luck

Pedro Batista gravatar imagePedro Batista ( 2014-03-11 05:04:11 -0600 )edit
1

answered 2014-03-25 05:16:08 -0600

Fr3@k gravatar image

It is working now. I found a mistake in my program-settings. The size of the Webcam-video was too small to detect the Object i trained the Classifier for. I resized the Window to the webcam-resolution. Now the cat-detection works fine. Even with the Haar-Classifier the results are acceptable but the LBP is much better ;)

Now I will implement your advice and make a new/better Classifier with positive Images taken from a Video.

Thanks for your help!

edit flag offensive delete link more

Comments

I've got a problem with the new Cascade Training. At Stage 8 I get this Error:

OpenCV Error: One of arguments' values is out of range (No components/input_variables is selected!) in cvPreprocessIndexArray, file /build/buildd/opencv-2.3.1/modules/ml/src/inner_functions.cpp, line 432 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.3.1/modules/ml/src/inner_functions.cpp:432: error: (-211) No components/input_variables is selected! in function cvPreprocessIndexArray

Any idea what the problem is?

This was the start of the classification: ./opencv_traincascade -data results -vec samples/yuki.vec -bg negatives/negatives.txt -numPos 1000 -numNeg 2000 -w 50 -h 50 -featureType LBP -precalcValBufSize 2048 -precalcIdxBufSize 2048

Fr3@k gravatar imageFr3@k ( 2014-04-05 17:03:12 -0600 )edit

Question Tools

Stats

Asked: 2014-03-05 11:51:43 -0600

Seen: 5,865 times

Last updated: Mar 25 '14