有名人に関する情報の取得 - Amazon Rekognition

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

有名人に関する情報の取得

以下の手順では、getCelebrityInfoAPI オペレーションを使用して有名人に関する情報を取得します。有名人を識別するには、前回の RecognizeCelebrities への呼び出しで返された有名人 ID を使用します。

呼び出し GetCelebrityInfo

以下の手順では、Amazon Rekognition で認識済みの有名人の ID が必要です。「イメージ内の有名人の認識」で書き留めた有名人 ID を使用します。

有名人に関する情報を取得するには (SDK)
  1. まだ実行していない場合:

    1. AmazonRekognitionFullAccessAmazonS3ReadOnlyAccess のアクセス権限を持つユーザーを作成または更新します。詳細については、「ステップ 1: AWS アカウントを設定してユーザーを作成する」を参照してください。

    2. AWS CLI と AWS SDK のインストールと設定 詳細については、「ステップ 2: AWS CLI と AWS SDKsを設定する」を参照してください。

  2. 以下の例を使用して、GetCelebrityInfo オペレーションを呼び出します。

    Java

    この例では、有名人の名前と情報を表示します。

    id は、「イメージ内の有名人の認識」で表示された有名人 ID のいずれかに置き換えます。

    //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); } } }
    Java V2

    このコードは、 AWSドキュメント SDK サンプル GitHub リポジトリから取得されます。詳しい事例は こちら を参照してください。

    import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.rekognition.RekognitionClient; import software.amazon.awssdk.services.rekognition.model.GetCelebrityInfoRequest; import software.amazon.awssdk.services.rekognition.model.GetCelebrityInfoResponse; import software.amazon.awssdk.services.rekognition.model.RekognitionException; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class CelebrityInfo { public static void main(String[] args) { final String usage = """ Usage: <id> Where: id - The id value of the celebrity. You can use the RecognizeCelebrities example to get the ID value.\s """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String id = args[0]; Region region = Region.US_EAST_1; RekognitionClient rekClient = RekognitionClient.builder() .region(region) .build(); getCelebrityInfo(rekClient, id); rekClient.close(); } public static void getCelebrityInfo(RekognitionClient rekClient, String id) { try { GetCelebrityInfoRequest info = GetCelebrityInfoRequest.builder() .id(id) .build(); GetCelebrityInfoResponse response = rekClient.getCelebrityInfo(info); System.out.println("celebrity name: " + response.name()); System.out.println("Further information (if available):"); for (String url : response.urls()) { System.out.println(url); } } catch (RekognitionException e) { System.out.println(e.getMessage()); System.exit(1); } } }
    AWS CLI

    この AWS CLI コマンドでは、get-celebrity-info CLI オペレーションの JSON 出力を表示します。ID は、「イメージ内の有名人の認識」で表示された有名人 ID のいずれかに置き換えます。profile-name の値を自分のデベロッパープロファイル名に置き換えます。

    aws rekognition get-celebrity-info --id celebrity-id --profile profile-name
    Python

    この例では、有名人の名前と情報を表示します。

    id は、「イメージ内の有名人の認識」で表示された有名人 ID のいずれかに置き換えます。Rekognition セッションを作成する行の profile_name の値を、自分のデベロッパープロファイル名に置き換えます。

    # 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.) import boto3 def get_celebrity_info(id): session = boto3.Session(profile_name='profile-name') client = session.client('rekognition') # Display celebrity info print('Getting celebrity info for celebrity: ' + id) response = client.get_celebrity_info(Id=id) print(response['Name']) print('Further information (if available):') for url in response['Urls']: print(url) def main(): id = "celebrity-id" celebrity_info = get_celebrity_info(id) if __name__ == "__main__": main()
    .NET

    この例では、有名人の名前と情報を表示します。

    id は、「イメージ内の有名人の認識」で表示された有名人 ID のいずれかに置き換えます。

    //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.) using System; using Amazon.Rekognition; using Amazon.Rekognition.Model; public class CelebrityInfo { public static void Example() { String id = "nnnnnnnn"; AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient(); GetCelebrityInfoRequest celebrityInfoRequest = new GetCelebrityInfoRequest() { Id = id }; Console.WriteLine("Getting information for celebrity: " + id); GetCelebrityInfoResponse celebrityInfoResponse = rekognitionClient.GetCelebrityInfo(celebrityInfoRequest); //Display celebrity information Console.WriteLine("celebrity name: " + celebrityInfoResponse.Name); Console.WriteLine("Further information (if available):"); foreach (String url in celebrityInfoResponse.Urls) Console.WriteLine(url); } }

GetCelebrityInfo オペレーションリクエスト

次の例は、GetCelebrityInfo の JSON 入力および出力です。

GetCelebrityInfo への入力は、必要な有名人の ID です。

{ "Id": "nnnnnnn" }

GetCelebrityInfo オペレーションレスポンス

GetCelebrityInfo は、必要な有名人に関する情報へのリンクの配列 (Urls) を返します。

{ "Name": "Celebrity Name", "Urls": [ "www.imdb.com/name/nmnnnnnnn" ] }