You are here

private function FocusScaleCropImageEffect::getFaceDetection in Image Focus Crop 8

Get Face detection.

Parameters

mixed $resource: Resource.

Return value

array|bool Points of false.

1 call to FocusScaleCropImageEffect::getFaceDetection()
FocusScaleCropImageEffect::getFocalPoint in src/Plugin/ImageEffect/FocusScaleCropImageEffect.php
Method getFocalPoint.

File

src/Plugin/ImageEffect/FocusScaleCropImageEffect.php, line 110

Class

FocusScaleCropImageEffect
Crops with focus an image resource.

Namespace

Drupal\image_focus\Plugin\ImageEffect

Code

private function getFaceDetection($resource) {
  $detector = new FaceDetector();
  $detector
    ->faceDetect($resource);
  if ($face = $detector
    ->getFace()) {
    return [
      $face['x'] + $face['w'] / 2,
      $face['y'] + $face['w'] / 2,
    ];
  }
  return FALSE;
}