Ask Your Question
0

opencv_traincascade detection phase: obtain confidence of each detection window

asked 2015-07-16 06:24:18 -0600

angela gravatar image

updated 2015-07-16 06:35:28 -0600

berak gravatar image

Has anyone created a recall precision curve for traincascade? I am thinking of doing this at the detection stage:

Looking at the docs, opencv provides this method:

Python: cv2.CascadeClassifier.detectMultiScale(image,rejectLevels, levelWeights[,scaleFactor[, minNeighbors[, flags[,minSize[, maxSize[,outputRejectLevels]]]]]]) → objects

My questions are:

  • What 'objects' are being returned by this method?
  • Assuming rejectLevels refers to the confidence level for each detection window, why do I need to pass it in as a parameter?
  • What do I need to pass in for rejectLevels and levelWeights?
  • What is outputRejectLevels? Is it related to how certain the cascade should be to accept a detection?
edit retag flag offensive close merge delete

Comments

1

hmm, opencv2.4 ? i 'm having some doubts , if this is useable at all (rejectLevels and levelWeights should be tagged CV_OUT, too here , else it won't return anything useful


in opencv3.0 it is:

 |  detectMultiScale3(...)
 |      detectMultiScale3(image[, scaleFactor[, minNeighbors[, flags[, minSize[,
 maxSize[, outputRejectLevels]]]]]]) -> objects, rejectLevels, levelWeights

objects are the returned rects, and imho it should not be nessecary to pass anything for rejectLevels and levelWeights

outputRejectLevels is a boolean flag, that must be set to true (bug, maybe...) it is only for "fill rejectLevels(or not)"

berak gravatar imageberak ( 2015-07-16 06:40:17 -0600 )edit

Help on CascadeClassifier object:

class CascadeClassifier(__builtin__.object) | Methods defined here: |
| __repr__(...) | x.__repr__() <==> repr(x) |
| detectMultiScale(...) | detectMultiScale(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]) -> objects or detectMultiScale(image, rejectLevels, levelWeights[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize[, outputRejectLevels]]]]]]) -> objects |
| empty(...) | empty() -> retval |
| load(...) | load(filename) -> retval |
| ---------------------------------------------------------------------- | Data and other attributes defined here: |
| __new__ = <built-in method="" __new__="" of="" type="" object=""> | T.__new__(S, ...) -> a new object with type S, a subtype of

angela gravatar imageangela ( 2015-07-16 06:42:59 -0600 )edit

it was present in the 3.0-beta, as I've mentioned in the answer. There were some numbers, but I couldn't use them at the time I was working on face detection; I think it was linked to the level of the cascade tree that rejected the sample, but not sure.

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-07-16 06:45:34 -0600 )edit

Thanks for comments. What do you mean by 'there were some numbers' but you 'couldn't use them'? Do you mean that confidence levels were provided but it wasn't clear what they meant so you chose not to use them? Also, so this funcionality was added for 3.0 then, right?

angela gravatar imageangela ( 2015-07-16 06:57:23 -0600 )edit

Maybe, I have tried to pick the detections with highest values, but they were totally wrong, and then with the lowest ones, but nothing interesting, they are int values, as you can see here

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-07-16 07:04:52 -0600 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2015-07-16 06:42:06 -0600

thdrksdfthmn gravatar image
  • The objects returned by CascadeClassifier::detectMultiScale are cv::Rect (or vector of 4 int in Python)
  • I suppose that it is an old doc (by the way, the link is for your question, not the docs), rejectLevels are for output as the docs say. An they will contain some numbers, if you set the flag outputRejectLevels; but I do not remember exactly what they mean, there is no doc on it, but you can test it.

I can tell you that I have used once rejectLevels or the levelWeights for having the best face-detection, but it was not as good as the groupRectangles function...

edit flag offensive delete link more

Comments

The link is broken? Sorry, it worked (and works) fine on my end.

The version I'm using is 2.4, and the function I include in my question is in the docs. But I'm not sure what I should pass in for the required parameters rejectLevels and levelWeights.

Also, what do you mean that groupRectangles is better? I don't know if it's relevant for my purpose. My goal is to have a Recall Precision curve, and therefore I want to be able to accept/reject more or less rectangles depending on some threshold. I was hoping the confidence level of the algorithm would be the threshold I could change.

angela gravatar imageangela ( 2015-07-16 07:00:57 -0600 )edit
1

(you had a pair of braces too much around the link, now it works)

berak gravatar imageberak ( 2015-07-16 07:09:04 -0600 )edit

You shall pass empty vectors (int for rejection and double for weights) and they will be filled, the index will make the link between the rectangle of detection and the other 2 values. Try it

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-07-16 07:09:36 -0600 )edit
1

i do not think, the 2.4 (python) version will work. (but yes, for c++, it will. just proceed as described above)

berak gravatar imageberak ( 2015-07-16 07:13:33 -0600 )edit

Yep, it looks like openCV 2.4 will just leave the vectors empy. :(

Sad truth is I don't know much C++ and I don't think I have the time for this project to figure it out. :(

Does the Python OpenCV 3.0 work or should I not bother installing it?

angela gravatar imageangela ( 2015-07-16 07:23:02 -0600 )edit
1

depending on your time, you could ofc. try to fix it for 2.4 (and maybe make a pr ;)

add CV_OUT in l. 404/405, and rebuild/install

yes, the opencv3 python version works, but i can't help you with the decision, if you want to move over to 3.0

berak gravatar imageberak ( 2015-07-16 07:33:08 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-07-16 06:24:18 -0600

Seen: 1,037 times

Last updated: Jul 16 '15