Ask Your Question

Control senstivity of object detector

asked 2013-01-22 01:06:17 -0500

rohitg gravatar image

I wanted to analyze the in-built object detector in opencv (CascadeClassifier, using Haar or Hog features). Is it possible to control the false positive or hit rate of the classifier? I would ideally like to plot an ROC or DET curve of the same.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-01-22 02:14:41 -0500

Siegfried gravatar image

Hi, in case of HoG you can vary the hit_threshold and group_threshold parameters of the detectMultiScale method to control the number of false positives and true positives.

From the opencv documentation gpu::HOGDescriptor::detectMultiScale (the CPU HoG documentation is currently missing, its a bug in the OpenCV documentation. But the GPU HoG has a quite similar interface so we can look a this one).

hit_threshold - Threshold for the distance between features and SVM classifying plane

group_threshold - Coefficient to regulate the similarity threshold. When detected, some objects can be covered by many rectangles. 0 means not to perform grouping. See groupRectangles())

In my project I am using MeanShiftGrouping=true. MeanShiftGrouping combines the detected rectangles and weights of the detected objects into one result. So we get an resulting rectangle and weight. This weight can be "threshold-ed" by using group_threshold. For the DET diagram in my project I am using therefore a small value for hit_threshold and vary then the group_threshold.

If you use the DET or ROC plot to find the "best" parameter setting for your application you should vary both, the hit_threshold and the group_threshold.

edit flag offensive delete link more


Thanks! that works. I also found a sample code for HoG in opencv/samples/cpp/peopledetect.cpp Can a similar setting be done for HAAR classifier?

rohitg gravatar imagerohitg ( 2013-01-22 07:59:15 -0500 )edit

Hi, take a look at the paper from Viola and Jones at figure 6 on page 12. The detection cascade looks like an unbalanced decision tree. At every layer a classifier is used to reject wrong hypotheses. Probably you can use the search depth in the decision tree as a kind of "weight". The CascadeClassifier::runAt() method provides this information (see

Siegfried gravatar imageSiegfried ( 2013-01-22 08:50:03 -0500 )edit

Question Tools

1 follower


Asked: 2013-01-22 01:06:17 -0500

Seen: 1,142 times

Last updated: Jan 22 '13