Vision Face#

Face#

Face class representing the Vision API’s face detection response.

class google.cloud.vision.face.Angles(roll, pan, tilt)[source]#

Bases: object

Angles representing the positions of a face.

classmethod from_api_repr(angle)[source]#

Factory: construct the angles from an Vision API response.

Parameters:angle (dict) – Dictionary representation of an angle.
Return type:Angles
Returns:An Angles instance with data parsed from response.
classmethod from_pb(angle)[source]#

Factory: convert protobuf Angle object to local Angle object.

Parameters:angle (FaceAnnotation) – Protobuf FaceAnnotation response with angle data.
Return type:Angles
Returns:Instance of Angles.
pan#

Pan angle of face.

Return type:float
Returns:Pan angle of face in degrees.
roll#

Roll angle of face.

Return type:float
Returns:Roll angle of face in degrees.
tilt#

Tilt angle of face.

Return type:float
Returns:Tilt angle of face in degrees.
class google.cloud.vision.face.Bounds(vertices)[source]#

Bases: google.cloud.vision.geometry.BoundsBase

The bounding polygon of the entire face.

class google.cloud.vision.face.Emotions(joy_likelihood, sorrow_likelihood, surprise_likelihood, anger_likelihood)[source]#

Bases: object

Emotions displayed by the face detected in an image.

anger#

Likelihood of anger in detected face.

Return type:str
Returns:String derived from Likelihood.
classmethod from_api_repr(emotions)[source]#

Factory: construct Emotions from Vision API response.

Parameters:emotions (dict) – Response dictionary representing a face.
Return type:Emotions
Returns:Populated instance of Emotions.
classmethod from_pb(emotions)[source]#

Factory: construct Emotions from Vision API response.

Parameters:emotions (FaceAnnotation) – Response dictionary representing a face with emotions.
Return type:Emotions
Returns:Populated instance of Emotions.
joy#

Likelihood of joy in detected face.

Return type:str
Returns:String derived from Likelihood.
sorrow#

Likelihood of sorrow in detected face.

Return type:str
Returns:String derived from Likelihood.
surprise#

Likelihood of surprise in detected face.

Return type:str
Returns:String derived from Likelihood.
class google.cloud.vision.face.FDBounds(vertices)[source]#

Bases: google.cloud.vision.geometry.BoundsBase

The bounding polygon of just the skin portion of the face.

class google.cloud.vision.face.Face(angles, bounds, detection_confidence, emotions, fd_bounds, headwear_likelihood, image_properties, landmarks, landmarking_confidence)[source]#

Bases: object

Representation of a face found by the Vision API

anger#

Accessor to likelihood that the detected face is angry.

Return type:str
Returns:String derived from Likelihood.
angles#

Accessor to the pan, tilt and roll angles of a Face.

Return type:Angles
Returns:Pan, tilt and roll angles of the detected face.
bounds#

Accessor to the bounding poly information of the detected face.

Return type:Bounds
Returns:An instance of Bounds which has a list of vertices.
detection_confidence#

Face detection confidence score determined by the Vision API.

Return type:float
Returns:Float representation of confidence ranging from 0 to 1.
emotions#

Accessor to the possible emotions expressed in the detected face.

Return type:Emotions
Returns:An instance of Emotions with joy, sorrow, anger, surprise likelihood.
fd_bounds#

Accessor to the skin area bounding poly of the detected face.

Return type:FDBounds
Returns:An instance of FDBounds which has a list of vertices.
classmethod from_api_repr(face)[source]#

Factory: construct an instance of a Face from an API response

Parameters:face (dict) – Face annotation dict returned from the Vision API.
Return type:Face
Returns:A instance of Face with data parsed from response.
classmethod from_pb(face)[source]#

Factory: construct an instance of a Face from an protobuf response

Parameters:face (AnnotateImageResponse) – AnnotateImageResponse from gRPC call.
Return type:Face
Returns:A instance of Face with data parsed from response.
headwear#

Headwear likelihood.

Return type:Likelihood
Returns:String representing the likelihood based on Likelihood
image_properties#

Image properties from imaged used in face detection.

Return type:FaceImageProperties
Returns:FaceImageProperties object with image properties.
joy#

Likelihood of joy in detected face.

Return type:str
Returns:String derived from Likelihood.
landmarking_confidence#

Landmarking confidence score determinged by the Vision API.

Return type:float
Returns:Float representing the confidence of the Vision API in determining the landmarks on a face.
landmarks#

Accessor to the facial landmarks detected in a face.

Return type:Landmarks
Returns:Landmarks object with facial landmarks as properies.
sorrow#

Likelihood of sorrow in detected face.

Return type:str
Returns:String derived from Likelihood.
surprise#

Likelihood of surprise in detected face.

Return type:str
Returns:String derived from Likelihood.
class google.cloud.vision.face.FaceImageProperties(blurred_likelihood, underexposed_likelihood)[source]#

Bases: object

A representation of the image properties from face detection.

blurred#

Likelihood of the image being blurred.

Return type:str
Returns:String representation derived from Position.
classmethod from_api_repr(face)[source]#

Factory: construct image properties from image.

Parameters:face (dict) – Dictionary representation of a Face.
Return type:FaceImageProperties
Returns:Instance populated with image property data.
classmethod from_pb(face)[source]#

Factory: construct image properties from image.

Parameters:face (                    FaceAnnotation) – Protobuf instace of Face.
Return type:FaceImageProperties
Returns:Instance populated with image property data.
underexposed#

Likelihood that the image used for detection was underexposed.

Return type:str
Returns:String representation derived from Position.
class google.cloud.vision.face.Landmark(position, landmark_type)[source]#

Bases: object

A face-specific landmark (for example, a face feature, left eye).

Parameters:
  • landmark_type (LandmarkTypes) – Instance of LandmarkTypes.
  • position (Position) –
classmethod from_api_repr(landmark)[source]#

Factory: construct an instance of a Landmark from a response.

Parameters:landmark (dict) – Landmark representation from Vision API.
Return type:Landmark
Returns:Populated instance of Landmark.
classmethod from_pb(landmark)[source]#

Factory: construct an instance of a Landmark from a response.

Parameters:landmark (Landmark) – Landmark representation from Vision API.
Return type:Landmark
Returns:Populated instance of Landmark.
landmark_type#

Landmark type of facial feature.

Return type:str
Returns:String representation of facial landmark type.
position#

Landmark position on face.

Return type:Position
Returns:Instance of Position with landmark coordinates.
class google.cloud.vision.face.LandmarkTypes[source]#

Bases: enum.Enum

A representation of the face detection landmark types.

See: https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#type_1

CHIN_GNATHION = 32#
CHIN_LEFT_GONION = 33#
CHIN_RIGHT_GONION = 34#
FOREHEAD_GLABELLA = 31#
LEFT_EAR_TRAGION = 27#
LEFT_EYE = 1#
LEFT_EYEBROW_UPPER_MIDPOINT = 25#
LEFT_EYE_BOTTOM_BOUNDARY = 19#
LEFT_EYE_LEFT_CORNER = 20#
LEFT_EYE_PUPIL = 29#
LEFT_EYE_RIGHT_CORNER = 18#
LEFT_EYE_TOP_BOUNDARY = 17#
LEFT_OF_LEFT_EYEBROW = 3#
LEFT_OF_RIGHT_EYEBROW = 5#
LOWER_LIP = 10#
MIDPOINT_BETWEEN_EYES = 7#
MOUTH_CENTER = 13#
MOUTH_LEFT = 11#
MOUTH_RIGHT = 12#
NOSE_BOTTOM_CENTER = 16#
NOSE_BOTTOM_LEFT = 15#
NOSE_BOTTOM_RIGHT = 14#
NOSE_TIP = 8#
RIGHT_EAR_TRAGION = 28#
RIGHT_EYE = 2#
RIGHT_EYEBROW_UPPER_MIDPOINT = 26#
RIGHT_EYE_BOTTOM_BOUNDARY = 23#
RIGHT_EYE_LEFT_CORNER = 24#
RIGHT_EYE_PUPIL = 30#
RIGHT_EYE_RIGHT_CORNER = 22#
RIGHT_EYE_TOP_BOUNDARY = 21#
RIGHT_OF_LEFT_EYEBROW = 4#
RIGHT_OF_RIGHT_EYEBROW = 6#
UNKNOWN_LANDMARK = 0#
UPPER_LIP = 9#
class google.cloud.vision.face.Landmarks(landmarks)[source]#

Bases: object

Landmarks detected on a face represented as properties.

Parameters:landmarks (list) – List of Landmark.
classmethod from_api_repr(landmarks)[source]#

Factory: construct facial landmarks from Vision API response.

Parameters:landmarks (dict) – JSON face annotation.
Return type:Landmarks
Returns:Instance of Landmarks populated with facial landmarks.
classmethod from_pb(landmarks)[source]#

Factory: construct facial landmarks from Vision gRPC response.

Parameters:landmarks (                         RepeatedCompositeFieldContainer) – List of facial landmarks.
Return type:Landmarks
Returns:Instance of Landmarks populated with facial landmarks.