Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Multi-detection #4

Domingo-montes opened this Issue Dec 31, 2012 · 14 comments


None yet
6 participants

I finded where to put comments but no familiarized with GitHUb already!!!

I mean the script will can detect more than one face on a pic, like some others around the web..


mauricesvay commented Dec 31, 2012

This library can only detect one face. Multiple face detection hasn't been implemented.

Hey Maurice,

I've had an idea about how to detect multiple faces by clearing the area of the canvas where one has been detected already and then rescanning. Can you give me any tips as to whether that's just crazy talk or where you'd start if you were going to implement it?

Hello again,

I've got multi-face detection working on my fork https://github.com/sanchothefat/php-facedetection/blob/master/FaceDetector.php

It's not perfect by any stretch. Overlapping face areas are a problem that I'm not too sure how to work around yet..


mauricesvay commented Feb 14, 2013

The original Javascript implementation had multiple face detection. You might look at it. Your fork is a pretty cool hack however :)

Merci :)

I'll check out the JS version. I've made a simple plugin that uses face detection in WordPress while it's cropping images here.

jostie commented Mar 6, 2013

Sanchothefat, can't you make the square smaller before removing it. Small enough to stop the recognition but leaving other faces detectable?

@jostie I don't remove the face but rather remember where it is and skip those points on the image. It's by no means perfect but I wasn't getting consistent results when I skipped over only half of a detected face for example. I couldn't pin down exactly how much face was enough to trigger detection in the end so I kept it simple. If you can figure it out let me know!

If you absolutely require face detection you'd have better luck using opencv directly with a php interface library if there is one. The php implementation is unfortunately very slow to run.

migandhi commented Jan 8, 2014

Example code for multi-detect faces https://drive.google.com/uc?authuser=0&id=0B3IOYEdd-pYSU2N5WTRHYWpfTW8&export=download , the name of the file is hard-coded as in the original sample. I have solved it painlessly , and continued detecting other faces. I didn't have any clue of the above comments. I have just color-filled the rectangle of the face,which allowed further detection. Drawback: here would be that a face may be cut and miss detection due to overlapped region of detection

@migandhi I tried your code, it seems a little too slow, however, are continuing to develop it or is it still? thanks ;)


mauricesvay commented Jan 9, 2014

If you have some spare time, you might want to have a look at the original JS implementation this lib was ported from: https://gist.github.com/mauricesvay/8332158

It had multi-face detection, but I only had the time to port the code for 1 face. It is probably more efficient to finish the port than to launch the 1-face detector multiple times.

migandhi commented Jan 9, 2014

Here an improvement that I see is that the image can be scaled to a thumbnail and then detection can proceed which doesn't have many pixels to scan....// exhaustive, but slow multiscale_detect() is the comment the coder has left in the .js ... that gives count of faces, then using that count the 1 face detection can be looped

migandhi commented Jan 9, 2014

and further improvement can be to scale up the same image co-ordinates if they can be mapped to the larger version


mauricesvay commented Jan 9, 2014

The PHP version already downsamples the image to perform face detection: https://github.com/mauricesvay/php-facedetection/blob/master/FaceDetector.php#L72-L83

migandhi commented Jan 9, 2014

// exhaustive, but slow multiscale_detect() https://gist.github.com/mauricesvay/8332158 in the .js is very true and can't be improved.. return ($this->face['w'] > 0) is the terminating condition as I have guessed it to be. if further scientific interest persists then FFT and Filters can be developed in a laboratory kind of environment... which I assume is available for free in colleges and other research facilities. Intel is a giant and can afford everything.. affordability does come as a constraint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment