Itay k
Itay k

Reputation: 4469

Is there a way to get a measurement of confidence level when using haar face detection using OpenCV?

I developed an application for face detection using OpenCVs HAAR cascade face detection. The algorithm works fine, however every once in a while It finds patterns on the wall or ather things that are not faces.
I want to run additional checks on object suspected as faces but I want to do it only on objects that I am not confidant that they are faces. Is there a way to get a "confidence" level for a face detected by the HAAR cascade face detection?

Upvotes: 10

Views: 9221

Answers (5)

Shaan Lashkari
Shaan Lashkari

Reputation: 1

OpenCV's HAAR Cascade Face detection is very weak.

I suggest you use teachable machines to train personally and use tensorflow option to retrieve the code.

In my coding, i used tensorflow and it gave me the confidence parameter

   probabilities = model.predict_proba(x)

i used this.

Upvotes: 0

MrGreen
MrGreen

Reputation: 147

Not a direct answer to your question, but this may help in reducing false detection.

You can get less false detection by tweaking MinNeibhbours, CV_HAAR_FIND_BIGGEST_OBJECT, and Size values.

int MinNeighbours = 7;

face_cascade.detectMultiScale( frame_gray, faces, 1.1, MinNeighbours, CV_HAAR_FIND_BIGGEST_OBJECT, Size(60, 60) );

Upvotes: 0

user3611413
user3611413

Reputation: 96

OpenCV provides the confidence via the argument "weights" in function "detectMultiScale" from class CascadeClassifier, you need to put the flag "outputRejectLevels" to true

Upvotes: 8

Bob Woodley
Bob Woodley

Reputation: 1284

Why not run multiple haar cascades (trained differently) against the same image and see if they produce similar results? Have them vote, as it were. Thus if only one cascade found a given face and the others didn't, that would give you less confidence in that given face.

I was able to run 3 cascades simultaneously on an iPhone video feed in real-time, so performance shouldn't be an issue in many normal scenarios. More here: http://rwoodley.org/?p=417

Upvotes: 1

Ja͢ck
Ja͢ck

Reputation: 173582

OpenCV actually finds more than one result for any particular object, each detected area largely overlapping each other; those are then grouped together and form a 'number of neighbours' count. This count is the so called confidence.

When you perform object detection, one of the parameters is the minimum neighbours before a hit is returned. Increasing it reduces false positives, but also decreases the number of possible detected faces.

Upvotes: 4

Related Questions