You are here

function image_focus_get_focal_point_face_detection in Image Focus Crop 7

Same name and namespace in other branches
  1. 6 image_focus.module \image_focus_get_focal_point_face_detection()

Get the focal point using Face Detection.

See also

http://svay.com/blog/face-detection-in-pure-php-without-opencv/

1 call to image_focus_get_focal_point_face_detection()
image_focus_get_focal_point in ./image_focus.module
Returns the focal point of the image.

File

./image_focus.module, line 65
Image Focus Crop module.

Code

function image_focus_get_focal_point_face_detection($resource) {
  module_load_include('php', 'image_focus', 'php-facedetection/FaceDetector');
  $detector = new Face_Detector(drupal_get_path('module', 'image_focus') . '/php-facedetection/detection.dat');
  $detector
    ->face_detect($resource);
  if ($face = $detector
    ->getFace()) {
    return array(
      $face['x'] + $face['w'] / 2,
      $face['y'] + $face['w'] / 2,
    );
  }
}