

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

# 有名人に関する情報の取得
<a name="get-celebrity-info-procedure"></a>

以下の手順では、[getCelebrityInfo](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetCelebrityInfo.html) API オペレーションを使用して有名人に関する情報を取得します。有名人を識別するには、前回の [RecognizeCelebrities](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_RecognizeCelebrities.html) への呼び出しで返された有名人 ID を使用します。

## GetCelebrityInfo の呼び出し
<a name="get-celebrity-info-examples"></a>



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

**有名人に関する情報を取得するには (SDK)**

1. まだ実行していない場合:

   1. `AmazonRekognitionFullAccess` と `AmazonS3ReadOnlyAccess` のアクセス権限を持つユーザーを作成または更新します。詳細については、「[ステップ 1: AWS アカウントを設定してユーザーを作成する](setting-up.md#setting-up-iam)」を参照してください。

   1.  AWS CLI および AWS SDKsをインストールして設定します。詳細については、「[ステップ 2: AWS CLI と AWS SDKsを設定する](setup-awscli-sdk.md)」を参照してください。

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

------
#### [ Java ]

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

   `id` は、「[イメージ内の有名人の認識](celebrities-procedure-image.md)」で表示された有名人 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 Documentation SDK サンプル GitHub リポジトリから取得されます。詳しい事例は[こちら](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/rekognition/src/main/java/com/example/rekognition/CelebrityInfo.java)です。

   ```
   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_WEST_2;
           RekognitionClient rekClient = RekognitionClient.builder()
                   .region(region)
                   .build();
   
           getCelebrityInfo(rekClient, id);
           rekClient.close();
       }
   
       /**
        * Retrieves information about a celebrity identified in an image.
        *
        * @param rekClient the Amazon Rekognition client used to make the API call
        * @param id the unique identifier of the celebrity
        * @throws RekognitionException if there is an error retrieving the celebrity information
        */
       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 コマンドは、 CLI オペレーションの JSON `get-celebrity-info` 出力を表示します。`ID` は、「[イメージ内の有名人の認識](celebrities-procedure-image.md)」で表示された有名人 ID のいずれかに置き換えます。`profile-name` の値を自分のデベロッパープロファイル名に置き換えます。

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

------
#### [ Python ]

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

   `id` は、「[イメージ内の有名人の認識](celebrities-procedure-image.md)」で表示された有名人 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` は、「[イメージ内の有名人の認識](celebrities-procedure-image.md)」で表示された有名人 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 オペレーションのリクエスト
<a name="getcelebrityinfo-operation-request"></a>

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

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

```
{
    "Id": "nnnnnnn"
}
```

## GetCelebrityInfo オペレーションの応答
<a name="getcelebrityinfo-operation-response"></a>

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

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