I am trying to use the example from here to detect a stop sign.

But when I change the image to search for stop signs in there are a huge number of false positives.

Am I doing something wrong?

  • $\begingroup$ Hi i'm also trying the trainCascadeObjectDetector for detecting people but it doesn't show me a good results someone could help me plz . my data set contains 270 negative images and 450 postive images . other question please i need to know haw to test haar feature in trainCascadeObjectDetector('personDetector.xml',data ,negativeFolder,'FalseAlarmRate', 0.2, 'NumCascadeStages',18); i know that hog is the default feature . thank you :) $\endgroup$
    – narjes
    Mar 25, 2015 at 10:31
  • $\begingroup$ Please do not use answer slots to ask similar questions. You can use the comments block under the question, or start a new thread if your case is different enough. $\endgroup$
    – sansuiso
    Mar 25, 2015 at 11:55

1 Answer 1


You are not doing anything wrong. This particular example is there for a quick illustration, and it does not produce a very good detector. It trains a 5-stage detector from a very small training set. A decent detector may have 20 stages or more, and you would need thousands of positive samples and negative images to train it.

Take a look at this tutorial for more information.

  • $\begingroup$ Okay, thanks for letting me know that. I have noticed that it actually works pretty good on images that contain stop signs about the same size (in pixels) as the test image. Do you happen to know of a more in depth explanation of how to train a cascade object detector in MATLAB than the one you provided? $\endgroup$
    – user8919
    May 29, 2014 at 4:53
  • $\begingroup$ Adding to what I previously wrote: So I guess you would say that the example is not very robust to changes in scale. I have read that the algorithm used is pretty robust to changes in scale though. Should I have to train the classifier with many different scales of the same images? $\endgroup$
    – user8919
    May 29, 2014 at 5:03
  • $\begingroup$ In this example the ObjectTrainingSize is set automatically to [33,32]. So stop signs smaller than that will not be detected, but the ones bigger than that should be. If they are not, then try decreasing ScaleFactor parameter of vision.CascadeObjectDetector. $\endgroup$
    – Dima
    May 29, 2014 at 13:56
  • $\begingroup$ I don't know of a better tutorial off hand. Is there anything specific that is not clear to you? Please keep in mind, that this is a toy example. You need vastly more data to get a useful object detector. Also keep in mind that stop signs at oblique angles are not likely to be detected, because they would have a different aspect ratio. $\endgroup$
    – Dima
    May 29, 2014 at 13:59
  • $\begingroup$ So the particular object I am trying to train the detector for has a pretty constant aspect ratio. But for my application the object is very wide compared to tall. So when I turn the object 90 degrees the object has the opposite aspect ratio. So do I need to train the detector with examples turned 90 degrees, or does the algorithm automatically train for orientation shifts in the plane like that? $\endgroup$
    – user8919
    May 29, 2014 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.