We can detect one face in an image using PHP.
Step 1: As we all know, how to upload an image using PHP. First, upload an image.
Step 2: After uploading an image (after upload script), Use FaceDetector class to detect the face area. This class use face detection algorithm (detection.dat file) to detect the face co-ordinate and dimension.
Step 3: By getting the co-ordinate and dimension, we can either marked the face area or crop the face area using crop functionality.
If an image don’t have face, it will not return any co-ordinate and dimension. We can also use this face detection script in mobile website.
But when we use face detection script using mobile camera snap, then we have to use image rotate function (imagerotate($source,$degrees,0)) to rotate the angle of image. Because face detection will only be possible with front face image. Image with horizontally lied face need to rotate angle.
Written by Amit Kumar, Sr. Software Engineer at Profit by Outsourcing