HaarObjectDetector - Facial Recognition-Min Image Size

286 views
Skip to first unread message

gai...@gmail.com

unread,
May 11, 2014, 5:18:41 PM5/11/14
to accor...@googlegroups.com
Is there a min image size to perform facial recognition with HaarObjectDetector? I have been tasked with performing facial recognition and cropping on images like the images attached and so far I have had no luck. If Arrord will work with images like the one attached, please provide guidance on how to set the settings? A code example would be excellent.

Thank you,
Adam

i_0ǵ.t_adfs_ABatsuk_MThumb.jpg
SFerrise.png

César

unread,
May 12, 2014, 5:31:10 AM5/12/14
to accor...@googlegroups.com
Hi Adam,

Yes, the framework might work on that. In order to do this, you can use the HaarObjectDetector as you mentioned. A fully functional example is given in the Face detection sample application, available with the framework installer. Once you install the framework, you will find a link to the sample applications (complete with source code) in your start menu. If you wish, you can also manually download the sample from here: http://dl.dropbox.com/u/32601472/accord/samples/accord-vision-face-detection-(viola-jones).zip

The source code can also be viewed online from here: https://github.com/accord-net/framework/blob/development/Samples/Vision/Face%20detection%20(Viola-Jones)/MainForm.cs. If you take a look at this linked source file, you will see the following code: 
 // Process frame to detect objects
 
Rectangle[] objects = detector.ProcessFrame(picture);

 
if (objects.Length > 0)
 
{
     
RectanglesMarker marker = new RectanglesMarker(objects, Color.Fuchsia);
      pictureBox1
.Image = marker.Apply(picture);
 
}

In your case, instead of just marking boxes around the faces as the sample application does, you can use the Crop filter to extract the face from the image.

In order to make the classifier work with the images you have provided, you might also need to tune it to allow for smaller detection windows. For this, you can try to use the following parameters, shown in the code below:

     HaarCascade cascade = new FaceHaarCascade();

     
var detector = new HaarObjectDetector(cascade, minSize: 12);
     detector
.SearchMode = ObjectDetectorSearchMode.NoOverlap;
     detector
.ScalingMode = ObjectDetectorScalingMode.SmallerToGreater;
     detector
.ScalingFactor = 1.1f;
     detector
.UseParallelProcessing = true;
     detector
.Suppression = 1;


Hope it helps!

Best regards,
Cesar
Reply all
Reply to author
Forward
0 new messages