Question

I have a final project about face detection. I decided to do this project using Matlab and the Computer Vision Toolbox because as you know, this toolbox uses Viola Jones Algorithm for object detection.

I wrote the code below but the code matches a face with the a non-face object.

Question
How can I change the code so that it matches faces only?

clear all
clc

% Read input image
I = imread('C:\imageprocessingwithMatlab\Image001.jpg');
figure,imshow(I);

%% Detect Faces in the image
% Create a detector object
faceDetector = vision.CascadeObjectDetector('FrontalFaceCART');   

% Detect faces
bbox = step(faceDetector, I); 

% Draw boxes around detected faces and display results
IFaces = insertObjectAnnotation(I, 'rectangle', bbox, 'Face');
figure, imshow(IFaces), title('Detected Faces');
Was it helpful?

Solution

Unfortunately, there is no guaranteed way to eliminate all false detections. However, you may be able to tweak some parameters to make the face detection work better on your particular image.

The first thing I would do is look at your false detections. If they tend to be larger or smaller than a typical face in your image, then you can try to adjust the MinSize and MaxSize parameters to get rid of them.

You can also try to use a different model, i. e. 'FrontalFaceLBP' instead of 'FrontalFaceCART'.

If that doesn't work, you can try a more clever trick. First detect the upper bodies of people using the 'UpperBody' classification model. Then detect the faces, and only keep the faces that are contained within upper bodies. This is likely to cut down on false detections, but you are also running a risk of missing real faces.

Finally, you can train your own face detector using the trainCascadeObjectDetector function. But that is definitely beyond the scope of your project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top