1

I have been using cascade classifier to train some kind of plants. Here is a sample image for what I want to detect

Litle green plants sample

I sampled the little green plants for positives, and made negatives out of images with similar background and no green plants (as suggested by many sources). Used many images similar to this one for sampling.

I did not have a lot of training data so of course I did not expect some idealistic classification results.

I have set the usual parameters min_hit_rate 0.95 max_false_alarm 0.5 etc. I have tried training with 5,6,7,8,9 and 10 stages. The strange thing that happens to me is that during the training process I get hit rate of 1 during all stages, and after 5 stages I get good acceptance ratio 0.004 (similar for later stages 6,7,8...). I tried testing my classifier on the same image which I used for the training samples and there is very illogical behavior:

  1. the classifier detects almost everything BUT the positive samples i took from it (the same samples in the training with HIT RATION EQUAL TO 1).
  2. the classifier is really but really slow it took over an hour for single input image (down-sampled scale factor 1.1).

I do not get it how could the same samples be classified as positives during training (through all the stages) and then NONE of it as positive on the image (there are a lot of false positives around it).

I checked everything a million times (I thought that I somehow mixed positives and negatives but I did not).

Can someone help me with this issue?

Delgan
  • 18,571
  • 11
  • 90
  • 141
user3847160
  • 98
  • 11
  • Do you like to use Haar classifiers definitely? Because the foreground and background is separated well in your case. You can also use color information which is a lack of information in the course of Haar. – Kornel Feb 20 '15 at 10:10
  • can you please add some of the positive and negative samples to the question, please? – Micka Feb 20 '15 at 13:01
  • I know that the other techniques would work well here, but I need to create a small example for cascade classifier on this type of images. As I said i dont expect it to work perfectly, but the problem is that the detector works bad on TRAINING DATA, and I had hit rate 1 throughout all the stages. – user3847160 Feb 20 '15 at 15:05
  • the positive samples are patches around green plants from the image I attached above, background are mostly from similar images but not containing green plants (gray background with some other thing etc). – user3847160 Feb 20 '15 at 15:06

1 Answers1

2

I can try and help but of course I can't train this thing for you unless you send me your images.

In my experience if you aren't getting the desired results, you are simply giving traincascade the wrong or not enough images (either or both positives or negatives).

I did not get great results until I created an annotation file using the built-in opencv_annotation tool. Have you done that? How many positives?

Did your negatives contain the background that you are attempting to detect your object in? This is key and can't be overlooked.

Also, I would use LBP, it's much faster.

If you or anyone is still stuck and have some positives created, send them to me and I'll see if I can train this thing.

And also, I have written hopefully a one-stop tutorial about this stuff after my experiences with it:

http://johnallen.github.io/opencv-object-detection-tutorial/

JohnAllen
  • 7,317
  • 9
  • 41
  • 65