PHP Class Google\Cloud\Vision\Annotation\Face\Landmarks

Example: use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $vision = $cloud->vision(); $imageResource = fopen(__DIR__ .'/assets/family-photo.jpg', 'r'); $image = $vision->image($imageResource, ['FACE_DETECTION']); $annotation = $vision->annotate($image); $faces = $annotation->faces(); $firstFace = $faces[0]; $landmarks = $firstFace->landmarks();
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#type_1 Face Landmark Types
Inheritance: extends Google\Cloud\Vision\Annotation\AbstractFeature
Datei anzeigen Open project: GoogleCloudPlatform/gcloud-php

Public Methods

Method Description
__construct ( array $info ) Create a landmarks results object.
chin ( ) : array Get the position of the chin.
ears ( ) : array Get the position of the ears.
forehead ( ) : array Get the position of the forehead glabella.
leftEye ( ) : array Fetch the left eye position.
leftEyeBoundaries ( ) : array Fetch the left eye boundaries.
leftEyePupil ( ) : array Fetch the left eye pupil position.
leftEyebrow ( ) : array Fetch the left eyebrow position.
lips ( ) : array Get the position of the lips.
midpointBetweenEyes ( ) : array Get the position of the midpoint beteeen the eyes.
mouth ( ) : array Get the position of the mouth.
nose ( ) : array Get the position of the nose.
rightEye ( ) : array Fetch the right eye position.
rightEyeBoundaries ( ) : array Fetch the right eye boundaries.
rightEyePupil ( ) : array Fetch the right eye pupil position.
rightEyebrow ( ) : array Fetch the right eyebrow position.

Private Methods

Method Description
getLandmark ( $type )

Method Details

__construct() public method

This class should not be instantiated directly. It is created internally by the Cloud Vision service wrapper to represent FACE_DETECTION annotation results and provide helpful convenience to users.
public __construct ( array $info )
$info array The face landmark results

chin() public method

This method returns an array with three keys: left, right, gnathion. The value of each of these keys is of the normal Position format described in the Cloud Vision documentation. Example: $positions = $landmarks->chin(); foreach ($positions as $name => $pos) { echo "Position Type: ". $name . PHP_EOL; echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL; }
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public chin ( ) : array
return array

ears() public method

This method returns an array with two keys: left and right. The value of each of these keys is of the normal Position format described in the Cloud Vision documentation. Example: $positions = $landmarks->ears(); foreach ($positions as $name => $pos) { echo "Position Type: ". $name . PHP_EOL; echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL; }
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public ears ( ) : array
return array

forehead() public method

Example: $pos = $landmarks->forehead(); echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL;
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public forehead ( ) : array
return array

leftEye() public method

Example: $pos = $landmarks->leftEye(); echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL;
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public leftEye ( ) : array
return array

leftEyeBoundaries() public method

This method returns an array with four keys: left, right, top, bottom. The value of each of these keys is of the normal Position format described in the Cloud Vision documentation. Example: $positions = $landmarks->leftEyeBoundaries(); foreach ($positions as $name => $pos) { echo "Position Type: ". $name . PHP_EOL; echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL; }
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public leftEyeBoundaries ( ) : array
return array

leftEyePupil() public method

Example: $pos = $landmarks->leftEyePupil(); echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL;
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public leftEyePupil ( ) : array
return array

leftEyebrow() public method

This method returns an array with three keys: left, right, upperMidpoint. The value of each of these keys is of the normal Position format described in the Cloud Vision documentation. Example: $positions = $landmarks->leftEyebrow(); foreach ($positions as $name => $pos) { echo "Position Type: ". $name . PHP_EOL; echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL; }
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public leftEyebrow ( ) : array
return array

lips() public method

This method returns an array with two keys: upper and lower. The value of each of these keys is of the normal Position format described in the Cloud Vision documentation. Example: $positions = $landmarks->lips(); foreach ($positions as $name => $pos) { echo "Position Type: ". $name . PHP_EOL; echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL; }
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public lips ( ) : array
return array

midpointBetweenEyes() public method

Example: $pos = $landmarks->midpointBetweenEyes(); echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL;
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public midpointBetweenEyes ( ) : array
return array

mouth() public method

This method returns an array with three keys: left, right, center. The value of each of these keys is of the normal Position format described in the Cloud Vision documentation. Example: $positions = $landmarks->mouth(); foreach ($positions as $name => $pos) { echo "Position Type: ". $name . PHP_EOL; echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL; }
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public mouth ( ) : array
return array

nose() public method

This method returns an array with four keys: tip, bottomRight, bottomLeft, bottomCenter. The value of each of these keys is of the normal Position format described in the Cloud Vision documentation. Example: $positions = $landmarks->nose(); foreach ($positions as $name => $pos) { echo "Position Type: ". $name . PHP_EOL; echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL; }
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public nose ( ) : array
return array

rightEye() public method

Example: $pos = $landmarks->rightEye(); echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL;
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public rightEye ( ) : array
return array

rightEyeBoundaries() public method

This method returns an array with four keys: left, right, top, bottom. The value of each of these keys is of the normal Position format described in the Cloud Vision documentation. Example: $positions = $landmarks->rightEyeBoundaries(); foreach ($positions as $name => $pos) { echo "Position Type: ". $name . PHP_EOL; echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL; }
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public rightEyeBoundaries ( ) : array
return array

rightEyePupil() public method

Example: $pos = $landmarks->rightEyePupil(); echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL;
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public rightEyePupil ( ) : array
return array

rightEyebrow() public method

This method returns an array with three keys: left, right, upperMidpoint. The value of each of these keys is of the normal Position format described in the Cloud Vision documentation. Example: $positions = $landmarks->rightEyebrow(); foreach ($positions as $name => $pos) { echo "Position Type: ". $name . PHP_EOL; echo "x position: ". $pos['x'] . PHP_EOL; echo "y position: ". $pos['y'] . PHP_EOL; echo "z position: ". $pos['z'] . PHP_EOL; }
See also: https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
public rightEyebrow ( ) : array
return array