PHP face detection class

Emanuele Feronato Php, Users contributions

Face detection is a computer technology that determines the locations and sizes of human faces in arbitrary (digital) images.

It detects facial features and ignores anything else, such as buildings, trees and bodies.

(source: Wikipedia)

There is so much to say about face detection and all its algorithms… I am planning a step by step tutorial about every branch of object detection in digital images, but first I want to publish Maurice Svay‘s PHP class.

Maurice, in his blog svay.com, explains he was looking for a face detection script for PHP, but wasn’t able to find one working without OpenCV (Open Source Computer Vision), an opensource lib that was originally developed by Intel.

OpenCV seems to perform well but you need to be able to install it on your server.

So he coded his own pure PHP solution, that does not require any library to be installed on the server.

And, obviously, that can be easily ported into any language. His class itself has been translated from a javascript code that actually is no longer available online

So this is the class:

Using it is very easy, just write

once you unpacked and included detection.dat and the image in the same path as your class.

Do you want to see a result?

This was generated by the script, just changing the frame color from red to green, to make it more visible.

The class does not work that well on every photo, but it’s a good start for a journey into face detection

Want to learn more? Learn by example!

Get the full commented source code of an actual commercial cross platform HTML5 game!!

Comments 38

  1. Pingback: Mal kurz rundgeschaut… #24 | Braekling.de

  2. Pingback: Face Detection Using PHP | blogfreakz.com

  3. Pingback: Detectar una cara en una foto usando PHP | Blog personal de Brian Urban

  4. Pingback: Face detection using PHP

  5. Pingback: PHP and Jquery face detection scripts « Webania.net

  6. Mohd

    Hay @Proger..

    At least it detected the face of Putin’s care :) I think PHP can’t recognize Putin.. same of the rest of us, this is logic.

  7. Dan

    I have two other Haar Xml files, is there any way to convert these to .dat files for use in this PHP implementation?

    Kind regards,

    Dan

  8. Pingback: ??????????? ?? ???? – PHP ????? | Siljanoski.com

  9. absfrm

    hello
    this is powerful.thanks to share
    but can you answer my question?
    i want to detect a face(save some detail for it as name or family).
    and when detect that face again , system show me his/her detail.
    can i do this action?
    thanks a lot

  10. Lakshmi Narayanan

    Hi this is great! Working fine with most of the complete and round faces. Thank u for the code! If you tweak the code further please let us know!

  11. Pingback: Flash AS3 face detection and recognition library - Emanuele Feronato

  12. Sander

    Face detection with PHP is not necessary, you can better use jQuery client side script.

    Search on Google for jQuery face detection and you will find it.

  13. suman

    programm is giving notice at line no 118 imagecolorat() out of bound ,,and also showing fatal error execution time exceed 30 sec in line 119 ,,,what i shoud do

  14. Pingback: jQuery face detection plugin - Emanuele Feronato

  15. devpk

    hye i need to compare thumb impression … is that library useful for matching thumb .thumb is store in mysql blob format. kindly suggest me links

Leave a Reply

Your email address will not be published. Required fields are marked *