In these procedures, you get celebrity information by using the getCelebrityInfo API operation. The celebrity is identified by using the celebrity ID that's returned from a previous call to RecognizeCelebrities.
Calling GetCelebrityInfo
These procedures require the celebrity ID for a celebrity that Amazon Rekognition knows. Use the celebrity ID that you note in Recognizing celebrities in an image.
To get celebrity information (SDK)
If you haven't already:
Create or update a user with
AmazonRekognitionFullAccess
andAmazonS3ReadOnlyAccess
permissions. For more information, see Step 1: Set up an AWS account and create a User.Install and configure the AWS CLI and AWS SDKs. For more information, see Step 2: Set up the AWS CLI and AWS SDKs.
Use the following examples to call the
GetCelebrityInfo
operation.This example displays the name and information about a celebrity.
Replace
id
with one of the celebrity IDs displayed in Recognizing celebrities in an image.//Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. //PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.) package aws.example.rekognition.image; import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder; import com.amazonaws.services.rekognition.model.GetCelebrityInfoRequest; import com.amazonaws.services.rekognition.model.GetCelebrityInfoResult; public class CelebrityInfo { public static void main(String[] args) { String id = "nnnnnnnn"; AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient(); GetCelebrityInfoRequest request = new GetCelebrityInfoRequest() .withId(id); System.out.println("Getting information for celebrity: " + id); GetCelebrityInfoResult result=rekognitionClient.getCelebrityInfo(request); //Display celebrity information System.out.println("celebrity name: " + result.getName()); System.out.println("Further information (if available):"); for (String url: result.getUrls()){ System.out.println(url); } } }
GetCelebrityInfo operation request
The following is example JSON input and output for GetCelebrityInfo
.
The input to GetCelebrityInfo
is the ID for the required celebrity.
{
"Id": "nnnnnnn"
}
GetCelebrityInfo operation response
GetCelebrityInfo
returns an array (Urls
) of links to information about the requested celebrity.
{
"Name": "Celebrity Name",
"Urls": [
"www.imdb.com/name/nmnnnnnnn"
]
}