Skip to content

Detect Faces

rekognition_detect_faces R Documentation

Detects faces within an image that is provided as input

Description

Detects faces within an image that is provided as input.

detect_faces detects the 100 largest faces in the image. For each face detected, the operation returns face details. These details include a bounding box of the face, a confidence value (that the bounding box contains a face), and a fixed set of attributes such as facial landmarks (for example, coordinates of eye and mouth), pose, presence of facial occlusion, and so on.

The face-detection algorithm is most effective on frontal faces. For non-frontal or obscured faces, the algorithm might not detect the faces or might detect faces with lower confidence.

You pass the input image either as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file.

This is a stateless API operation. That is, the operation does not persist any data.

This operation requires permissions to perform the rekognition:DetectFaces action.

Usage

rekognition_detect_faces(Image, Attributes)

Arguments

Image

[required] The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing base64-encoded image bytes is not supported.

If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the Bytes field. For more information, see Images in the Amazon Rekognition developer guide.

Attributes

An array of facial attributes you want to be returned. A DEFAULT subset of facial attributes - BoundingBox, Confidence, Pose, Quality, and Landmarks - will always be returned. You can request for specific facial attributes (in addition to the default list) - by using [⁠"DEFAULT", "FACE_OCCLUDED"⁠] or just ["FACE_OCCLUDED"]. You can request for all facial attributes by using [⁠"ALL"]⁠. Requesting more attributes may increase response time.

If you provide both, ⁠["ALL", "DEFAULT"]⁠, the service uses a logical "AND" operator to determine which attributes to return (in this case, all attributes).

Note that while the FaceOccluded and EyeDirection attributes are supported when using detect_faces, they aren't supported when analyzing videos with start_face_detection and get_face_detection.

Value

A list with the following syntax:

list(
  FaceDetails = list(
    list(
      BoundingBox = list(
        Width = 123.0,
        Height = 123.0,
        Left = 123.0,
        Top = 123.0
      ),
      AgeRange = list(
        Low = 123,
        High = 123
      ),
      Smile = list(
        Value = TRUE|FALSE,
        Confidence = 123.0
      ),
      Eyeglasses = list(
        Value = TRUE|FALSE,
        Confidence = 123.0
      ),
      Sunglasses = list(
        Value = TRUE|FALSE,
        Confidence = 123.0
      ),
      Gender = list(
        Value = "Male"|"Female",
        Confidence = 123.0
      ),
      Beard = list(
        Value = TRUE|FALSE,
        Confidence = 123.0
      ),
      Mustache = list(
        Value = TRUE|FALSE,
        Confidence = 123.0
      ),
      EyesOpen = list(
        Value = TRUE|FALSE,
        Confidence = 123.0
      ),
      MouthOpen = list(
        Value = TRUE|FALSE,
        Confidence = 123.0
      ),
      Emotions = list(
        list(
          Type = "HAPPY"|"SAD"|"ANGRY"|"CONFUSED"|"DISGUSTED"|"SURPRISED"|"CALM"|"UNKNOWN"|"FEAR",
          Confidence = 123.0
        )
      ),
      Landmarks = list(
        list(
          Type = "eyeLeft"|"eyeRight"|"nose"|"mouthLeft"|"mouthRight"|"leftEyeBrowLeft"|"leftEyeBrowRight"|"leftEyeBrowUp"|"rightEyeBrowLeft"|"rightEyeBrowRight"|"rightEyeBrowUp"|"leftEyeLeft"|"leftEyeRight"|"leftEyeUp"|"leftEyeDown"|"rightEyeLeft"|"rightEyeRight"|"rightEyeUp"|"rightEyeDown"|"noseLeft"|"noseRight"|"mouthUp"|"mouthDown"|"leftPupil"|"rightPupil"|"upperJawlineLeft"|"midJawlineLeft"|"chinBottom"|"midJawlineRight"|"upperJawlineRight",
          X = 123.0,
          Y = 123.0
        )
      ),
      Pose = list(
        Roll = 123.0,
        Yaw = 123.0,
        Pitch = 123.0
      ),
      Quality = list(
        Brightness = 123.0,
        Sharpness = 123.0
      ),
      Confidence = 123.0,
      FaceOccluded = list(
        Value = TRUE|FALSE,
        Confidence = 123.0
      ),
      EyeDirection = list(
        Yaw = 123.0,
        Pitch = 123.0,
        Confidence = 123.0
      )
    )
  ),
  OrientationCorrection = "ROTATE_0"|"ROTATE_90"|"ROTATE_180"|"ROTATE_270"
)

Request syntax

svc$detect_faces(
  Image = list(
    Bytes = raw,
    S3Object = list(
      Bucket = "string",
      Name = "string",
      Version = "string"
    )
  ),
  Attributes = list(
    "DEFAULT"|"ALL"|"AGE_RANGE"|"BEARD"|"EMOTIONS"|"EYE_DIRECTION"|"EYEGLASSES"|"EYES_OPEN"|"GENDER"|"MOUTH_OPEN"|"MUSTACHE"|"FACE_OCCLUDED"|"SMILE"|"SUNGLASSES"
  )
)

Examples

## Not run: 
# This operation detects faces in an image stored in an AWS S3 bucket.
svc$detect_faces(
  Image = list(
    S3Object = list(
      Bucket = "mybucket",
      Name = "myphoto"
    )
  )
)

## End(Not run)