

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

# ローカルファイルシステムからロードしたイメージの分析
<a name="images-bytes"></a>

Amazon Rekognition Image は、Amazon S3 バケットに保存されたイメージ、またはイメージのバイトとして提供されたイメージを分析できます。

以下のトピックでは、ローカルファイルシステムからロードしたファイルを使用して、Amazon Rekognition Image API オペレーションにイメージのバイトを渡す例を示します。イメージのバイトを Amazon Rekognition Image API オペレーションに渡すには [Image](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_Image.html) 入力パラメータを使用します。`Image` 内で `Bytes` プロパティを指定し、base64 エンコードされたイメージのバイトを渡します。

`Bytes` 入力パラメータを使用して Amazon Rekognition API オペレーションに渡すイメージのバイトは、base64 でエンコードする必要があります。以下の例で使用する AWS SDK では、イメージを自動的に base64 でエンコードします。Amazon Rekognition API オペレーションを呼び出す前にイメージのバイトをエンコードする必要はありません。詳細については、「[イメージの仕様](images-information.md)」を参照してください。

次の `DetectLabels` に対する JSON リクエストの例では、ソースイメージのバイトを `Bytes` 入力パラメータで渡します。

```
{
    "Image": {
        "Bytes": "/9j/4AAQSk....."
    },
    "MaxLabels": 10,
    "MinConfidence": 77
}
```

次の例では AWS SDKs と を使用して AWS CLI を呼び出します`DetectLabels`。`DetectLabels` オペレーションからのレスポンスの詳細については、「[DetectLabels のレスポンス](labels-detect-labels-image.md#detectlabels-response)」を参照してください。

クライアント側の JavaScript の例については、「[JavaScript を使用する](image-bytes-javascript.md)」を参照してください。

**ローカルイメージ内のラベルを検出するには**

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

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

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

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

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

   次の Java の例では、ローカルファイルシステムからイメージをロードし、[detectLabels](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/rekognition/model/DetectLabelsRequest.html) AWS SDK オペレーションを使用してラベルを検出する方法を示します。`photo` の値は、イメージファイル (.jpg 形式または .png 形式) のパスとファイル名に変更します。

   ```
   //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 java.io.File;
   import java.io.FileInputStream;
   import java.io.InputStream;
   import java.nio.ByteBuffer;
   import java.util.List;
   import com.amazonaws.services.rekognition.AmazonRekognition;
   import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder;
   import com.amazonaws.AmazonClientException;
   import com.amazonaws.services.rekognition.model.AmazonRekognitionException;
   import com.amazonaws.services.rekognition.model.DetectLabelsRequest;
   import com.amazonaws.services.rekognition.model.DetectLabelsResult;
   import com.amazonaws.services.rekognition.model.Image;
   import com.amazonaws.services.rekognition.model.Label;
   import com.amazonaws.util.IOUtils;
   
   public class DetectLabelsLocalFile {
       public static void main(String[] args) throws Exception {
       	String photo="input.jpg";
   
   
           ByteBuffer imageBytes;
           try (InputStream inputStream = new FileInputStream(new File(photo))) {
               imageBytes = ByteBuffer.wrap(IOUtils.toByteArray(inputStream));
           }
   
   
           AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient();
   
           DetectLabelsRequest request = new DetectLabelsRequest()
                   .withImage(new Image()
                           .withBytes(imageBytes))
                   .withMaxLabels(10)
                   .withMinConfidence(77F);
   
           try {
   
               DetectLabelsResult result = rekognitionClient.detectLabels(request);
               List <Label> labels = result.getLabels();
   
               System.out.println("Detected labels for " + photo);
               for (Label label: labels) {
                  System.out.println(label.getName() + ": " + label.getConfidence().toString());
               }
   
           } catch (AmazonRekognitionException e) {
               e.printStackTrace();
           }
   
       }
   }
   ```

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

   次の [AWS SDK for Python](https://aws.amazon.com/sdk-for-python/) の例では、ローカルファイルシステムからイメージをロードし、[detect\$1labels](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rekognition.html#Rekognition.Client.detect_labels) オペレーションを呼び出す方法を示します。`photo` の値は、イメージファイル (.jpg 形式または .png 形式) のパスとファイル名に変更します。

   ```
   #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 detect_labels_local_file(photo):
   
   
       client=boto3.client('rekognition')
      
       with open(photo, 'rb') as image:
           response = client.detect_labels(Image={'Bytes': image.read()})
           
       print('Detected labels in ' + photo)    
       for label in response['Labels']:
           print (label['Name'] + ' : ' + str(label['Confidence']))
   
       return len(response['Labels'])
   
   def main():
       photo='photo'
   
       label_count=detect_labels_local_file(photo)
       print("Labels detected: " + str(label_count))
   
   
   if __name__ == "__main__":
       main()
   ```

------
#### [ .NET ]

   次の の例では、ローカルファイルシステムからイメージをロードし、`DetectLabels` オペレーションを使用してラベルを検出する方法を示します。`photo` の値は、イメージファイル (.jpg 形式または .png 形式) のパスとファイル名に変更します。

   ```
   //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 System.IO;
   using Amazon.Rekognition;
   using Amazon.Rekognition.Model;
   
   public class DetectLabelsLocalfile
   {
       public static void Example()
       {
           String photo = "input.jpg";
   
           Amazon.Rekognition.Model.Image image = new Amazon.Rekognition.Model.Image();
           try
           {
               using (FileStream fs = new FileStream(photo, FileMode.Open, FileAccess.Read))
               {
                   byte[] data = null;
                   data = new byte[fs.Length];
                   fs.Read(data, 0, (int)fs.Length);
                   image.Bytes = new MemoryStream(data);
               }
           }
           catch (Exception)
           {
               Console.WriteLine("Failed to load file " + photo);
               return;
           }
   
           AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient();
   
           DetectLabelsRequest detectlabelsRequest = new DetectLabelsRequest()
           {
               Image = image,
               MaxLabels = 10,
               MinConfidence = 77F
           };
   
           try
           {
               DetectLabelsResponse detectLabelsResponse = rekognitionClient.DetectLabels(detectlabelsRequest);
               Console.WriteLine("Detected labels for " + photo);
               foreach (Label label in detectLabelsResponse.Labels)
                   Console.WriteLine("{0}: {1}", label.Name, label.Confidence);
           }
           catch (Exception e)
           {
               Console.WriteLine(e.Message);
           }
       }
   }
   ```

------
#### [ PHP ]

   次の [AWS SDK for PHP](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/welcome.html#getting-started) の例では、ローカルファイルシステムからイメージをロードし、[DetectFaces](https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#detectfaces) API オペレーションを呼び出します。`photo` の値は、イメージファイル (.jpg 形式または .png 形式) のパスとファイル名に変更します。

   ```
   
   <?php
   //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.)
   
       require 'vendor/autoload.php';
   
       use Aws\Rekognition\RekognitionClient;
   
       $options = [
          'region'            => 'us-west-2',
           'version'           => 'latest'
       ];
   
       $rekognition = new RekognitionClient($options);
   	
       // Get local image
       $photo = 'input.jpg';
       $fp_image = fopen($photo, 'r');
       $image = fread($fp_image, filesize($photo));
       fclose($fp_image);
   
   
       // Call DetectFaces
       $result = $rekognition->DetectFaces(array(
          'Image' => array(
             'Bytes' => $image,
          ),
          'Attributes' => array('ALL')
          )
       );
   
       // Display info for each detected person
       print 'People: Image position and estimated age' . PHP_EOL;
       for ($n=0;$n<sizeof($result['FaceDetails']); $n++){
   
         print 'Position: ' . $result['FaceDetails'][$n]['BoundingBox']['Left'] . " "
         . $result['FaceDetails'][$n]['BoundingBox']['Top']
         . PHP_EOL
         . 'Age (low): '.$result['FaceDetails'][$n]['AgeRange']['Low']
         .  PHP_EOL
         . 'Age (high): ' . $result['FaceDetails'][$n]['AgeRange']['High']
         .  PHP_EOL . PHP_EOL;
       }
   ?>
   ```

------
#### [ Ruby ]

   この例では、入力イメージ内で検出されたラベルのリストを表示します。`photo` の値は、イメージファイル (.jpg 形式または .png 形式) のパスとファイル名に変更します。

   ```
   #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.)
   
       # gem 'aws-sdk-rekognition'
       require 'aws-sdk-rekognition'
       credentials = Aws::Credentials.new(
          ENV['AWS_ACCESS_KEY_ID'],
          ENV['AWS_SECRET_ACCESS_KEY']
       )
       client   = Aws::Rekognition::Client.new credentials: credentials
       photo = 'photo.jpg'
       path = File.expand_path(photo) # expand path relative to the current directory
       file = File.read(path)
       attrs = {
         image: {
           bytes: file
         },
         max_labels: 10
       }
       response = client.detect_labels attrs
       puts "Detected labels for: #{photo}"
       response.labels.each do |label|
         puts "Label:      #{label.name}"
         puts "Confidence: #{label.confidence}"
         puts "Instances:"
         label['instances'].each do |instance|
           box = instance['bounding_box']
           puts "  Bounding box:"
           puts "    Top:        #{box.top}"
           puts "    Left:       #{box.left}"
           puts "    Width:      #{box.width}"
           puts "    Height:     #{box.height}"
           puts "  Confidence: #{instance.confidence}"
         end
         puts "Parents:"
         label.parents.each do |parent|
           puts "  #{parent.name}"
         end
         puts "------------"
         puts ""
       end
   ```

------
#### [ 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/DetectLabels.java) を参照してください。

   ```
   import software.amazon.awssdk.core.SdkBytes;
   import software.amazon.awssdk.regions.Region;
   import software.amazon.awssdk.services.rekognition.RekognitionClient;
   import software.amazon.awssdk.services.rekognition.model.*;
   
   import java.io.FileInputStream;
   import java.io.FileNotFoundException;
   import java.io.InputStream;
   import java.util.List;
   
   /**
    * 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 DetectLabels {
       public static void main(String[] args) {
           final String usage = """
               Usage: <bucketName> <sourceImage>
   
               Where:
                   bucketName - The name of the Amazon S3 bucket where the image is stored
                   sourceImage - The name of the image file (for example, pic1.png).\s
               """;
   
           if (args.length != 2) {
               System.out.println(usage);
               System.exit(1);
           }
   
           String bucketName = args[0] ;
           String sourceImage = args[1] ;
           Region region = Region.US_WEST_2;
           RekognitionClient rekClient = RekognitionClient.builder()
                   .region(region)
                   .build();
   
           detectImageLabels(rekClient, bucketName, sourceImage);
           rekClient.close();
       }
   
       /**
        * Detects the labels in an image stored in an Amazon S3 bucket using the Amazon Rekognition service.
        *
        * @param rekClient     the Amazon Rekognition client used to make the detection request
        * @param bucketName    the name of the Amazon S3 bucket where the image is stored
        * @param sourceImage   the name of the image file to be analyzed
        */
       public static void detectImageLabels(RekognitionClient rekClient, String bucketName, String sourceImage) {
           try {
               S3Object s3ObjectTarget = S3Object.builder()
                       .bucket(bucketName)
                       .name(sourceImage)
                       .build();
   
               Image souImage = Image.builder()
                       .s3Object(s3ObjectTarget)
                       .build();
   
               DetectLabelsRequest detectLabelsRequest = DetectLabelsRequest.builder()
                       .image(souImage)
                       .maxLabels(10)
                       .build();
   
               DetectLabelsResponse labelsResponse = rekClient.detectLabels(detectLabelsRequest);
               List<Label> labels = labelsResponse.labels();
               System.out.println("Detected labels for the given photo");
               for (Label label : labels) {
                   System.out.println(label.name() + ": " + label.confidence().toString());
               }
   
           } catch (RekognitionException e) {
               System.out.println(e.getMessage());
               System.exit(1);
           }
       }
   }
   ```

------

# JavaScript を使用する
<a name="image-bytes-javascript"></a>

次の JavaScript ウェブページの例では、ユーザーがイメージを選択し、そのイメージで検出された顔の推定年齢を表示することを許可します。推定年齢は [DetectFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html) を呼び出すと返されます。

選択したイメージは、JavaScript の `FileReader.readAsDataURL` 関数を使用してロードされます。これに伴って、イメージは base64 でエンコードされます。これは、HTML キャンバスでイメージを表示するのに役立ちます。ただし、イメージバイトを Amazon Rekognition Image オペレーションに渡す前にエンコードされていない状態にする必要があります。この例では、ロードされたイメージバイトをエンコードされていない状態にする方法を示しています。エンコードされたイメージバイトが有用でない場合は、代わりにロードされたイメージがエンコードされない `FileReader.readAsArrayBuffer` を使用します。つまり、最初にイメージバイトをエンコードされていない状態にする処理なしで、Amazon Rekognition Image オペレーションを呼び出すことができます。例については、[readAsArrayBuffer を使用する](#image-bytes-javascript-unencoded)を参照してください。

**JavaScript の例を実行するには**

1. ソースコード例をエディタにロードします。

1. Amazon Cognito identity プールの識別子を取得します。詳細については、「[Amazon Cognito identity プールの識別を取得します。](#image-bytes-javascript-auth)」を参照してください。

1. コード例の `AnonLog` 関数で、`IdentityPoolIdToUse` と `RegionToUse` は「[Amazon Cognito identity プールの識別を取得します。](#image-bytes-javascript-auth)」のステップ 9 で書き留めた値に変更します。

1. `DetectFaces` 関数の `RegionToUse` を、前のステップで使用した値に変更します。

1. ソースコード例を `.html` ファイルとして保存します。

1. ブラウザにファイルをロードします。

1. [**参照...**] ボタンを選択して、1 つ以上の顔が含まれたイメージを選択します。イメージ内で検出された顔ごとの推定年齢が含まれたテーブルが表示されます。

**注記**  
以下のコード例では、Amazon Cognito に含まれなくなった 2 つのスクリプトを使用しています。これらのファイルを取得するには、[aws-cognito-sdk.min.js](https://raw.githubusercontent.com/aws/amazon-cognito-identity-js/master/dist/aws-cognito-sdk.js) および [amazon-cognito-identity.min.js](https://raw.githubusercontent.com/aws/amazon-cognito-identity-js/master/dist/amazon-cognito-identity.min.js) のリンクをたどり、それぞれのテキストを個別の `.js` ファイルとして保存します。

## JavaScript のコード例
<a name="image-bytes-javascript-code"></a>

次のコード例では JavaScript V2 を使用しています。JavaScript V3 の例については、[AWS 「Documentation SDK examples GitHub repository」の「例」を参照してください。](https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javascriptv3/example_code/rekognition/estimate-age-example/src)

```
<!--
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.)
-->
<!DOCTYPE html>
<html>
<head>
  <script src="aws-cognito-sdk.min.js"></script>
  <script src="amazon-cognito-identity.min.js"></script>
  <script src="https://sdk.amazonaws.com/js/aws-sdk-2.16.0.min.js"></script>
  <meta charset="UTF-8">
  <title>Rekognition</title>
</head>

<body>
  <H1>Age Estimator</H1>
  <input type="file" name="fileToUpload" id="fileToUpload" accept="image/*">
  <p id="opResult"></p>
</body>
<script>

  document.getElementById("fileToUpload").addEventListener("change", function (event) {
    ProcessImage();
  }, false);
  
  //Calls DetectFaces API and shows estimated ages of detected faces
  function DetectFaces(imageData) {
    AWS.region = "RegionToUse";
    var rekognition = new AWS.Rekognition();
    var params = {
      Image: {
        Bytes: imageData
      },
      Attributes: [
        'ALL',
      ]
    };
    rekognition.detectFaces(params, function (err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else {
       var table = "<table><tr><th>Low</th><th>High</th></tr>";
        // show each face and build out estimated age table
        for (var i = 0; i < data.FaceDetails.length; i++) {
          table += '<tr><td>' + data.FaceDetails[i].AgeRange.Low +
            '</td><td>' + data.FaceDetails[i].AgeRange.High + '</td></tr>';
        }
        table += "</table>";
        document.getElementById("opResult").innerHTML = table;
      }
    });
  }
  //Loads selected image and unencodes image bytes for Rekognition DetectFaces API
  function ProcessImage() {
    AnonLog();
    var control = document.getElementById("fileToUpload");
    var file = control.files[0];

    // Load base64 encoded image 
    var reader = new FileReader();
    reader.onload = (function (theFile) {
      return function (e) {
        var img = document.createElement('img');
        var image = null;
        img.src = e.target.result;
        var jpg = true;
        try {
          image = atob(e.target.result.split("data:image/jpeg;base64,")[1]);

        } catch (e) {
          jpg = false;
        }
        if (jpg == false) {
          try {
            image = atob(e.target.result.split("data:image/png;base64,")[1]);
          } catch (e) {
            alert("Not an image file Rekognition can process");
            return;
          }
        }
        //unencode image bytes for Rekognition DetectFaces API 
        var length = image.length;
        imageBytes = new ArrayBuffer(length);
        var ua = new Uint8Array(imageBytes);
        for (var i = 0; i < length; i++) {
          ua[i] = image.charCodeAt(i);
        }
        //Call Rekognition  
        DetectFaces(ua);
      };
    })(file);
    reader.readAsDataURL(file);
  }
  //Provides anonymous log on to AWS services
  function AnonLog() {
    
    // Configure the credentials provider to use your identity pool
    AWS.config.region = 'RegionToUse'; // Region
    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
      IdentityPoolId: 'IdentityPoolIdToUse',
    });
    // Make the call to obtain credentials
    AWS.config.credentials.get(function () {
      // Credentials will be available when this function is called.
      var accessKeyId = AWS.config.credentials.accessKeyId;
      var secretAccessKey = AWS.config.credentials.secretAccessKey;
      var sessionToken = AWS.config.credentials.sessionToken;
    });
  }
</script>
</html>
```

### readAsArrayBuffer を使用する
<a name="image-bytes-javascript-unencoded"></a>

次のコードスニペットは、JavaScript V2 を使用したサンプルコード内の `ProcessImage` 関数の代替の実装です。`readAsArrayBuffer` を使用してイメージを読み込み、`DetectFaces` を呼び出します。ロードしたファイルは `readAsArrayBuffer` で base64 エンコードされないため、Amazon Rekognition オペレーションを呼び出す前にイメージのバイトをエンコード解除する必要はありません。

```
//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.)

function ProcessImage() {
    AnonLog();
    var control = document.getElementById("fileToUpload");
    var file = control.files[0];

    // Load base64 encoded image for display 
    var reader = new FileReader();
    reader.onload = (function (theFile) {
      return function (e) {
        //Call Rekognition  
        AWS.region = "RegionToUse";  
        var rekognition = new AWS.Rekognition();
        var params = {
          Image: {
          Bytes: e.target.result
        },
        Attributes: [
        'ALL',
      ]
    };
    rekognition.detectFaces(params, function (err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else {
       var table = "<table><tr><th>Low</th><th>High</th></tr>";
        // show each face and build out estimated age table
        for (var i = 0; i < data.FaceDetails.length; i++) {
          table += '<tr><td>' + data.FaceDetails[i].AgeRange.Low +
            '</td><td>' + data.FaceDetails[i].AgeRange.High + '</td></tr>';
        }
        table += "</table>";
        document.getElementById("opResult").innerHTML = table;
      }
    });

      };
    })(file);
    reader.readAsArrayBuffer(file);
  }
```

## Amazon Cognito identity プールの識別を取得します。
<a name="image-bytes-javascript-auth"></a>

わかりやすいように、この例では、匿名の Amazon Cognito identity プールを使用して、 Amazon Rekognition Image API に認証されていないアクセスを提供します。これは、お客様のニーズに適している場合もあります。たとえば、認証されていないアクセスを使用して、ユーザーがサインアップする前に、無料または試用でウェブサイトにアクセスできるようにできます。認証されたアクセスを提供するには、Amazon Cognito ユーザープールを使用します。詳細については、[Amazon Cognito ID ユーザープール](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html) を参照してください。

以下の手順では、認証されていない ID へのアクセスを有効にする ID プールを作成する方法と、コード例で必要な ID プールの ID を取得する方法を説明します。

**ID プールの ID を取得するには**

1. [Amazon Cognito コンソール](https://console.aws.amazon.com/cognito/federated)を開きます。

1. [**Create new identity pool**] を選択します。

1. [**ID プール名\$1**] に ID プールの名前を入力します。

1. [**認証されていない ID**] で、[**認証されていない ID に対してアクセスを有効にする**] を選択します。

1. **[プールの作成]** を選択します。

1. [**詳細の表示**] を選択して、認証されていない ID のロール名をメモします。

1. [**許可**] を選択します。

1. [**プラットフォーム**] で [**JavaScript**] を選択します。

1. [**AWS 認証情報の取得**] で、コードスニペットに表示される `AWS.config.region` と `IdentityPooldId` の値をメモします。

1. IAM コンソール ([https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/)) を開きます。

1. ナビゲーションペインで **Roles (ロール) ** を選択してください。

1. ステップ 6 で書き留めたロール名を選択します。

1. [**アクセス許可**] タブで、[**ポリシーのアタッチ**] を選択します。

1. [**AmazonRekognitionReadOnlyAccess**] を選択します。

1. ［**ポリシーをアタッチ**] を選択します。