

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Menganalisis citra yang dimuat dari sistem file lokal
<a name="images-bytes"></a>

Operasi Amazon Rekognition Image dapat menganalisis citra yang disediakan sebagai bit citra atau citra yang disimpan dalam bucket Amazon S3.

Topik ini memberikan contoh menyediakan bit citra untuk operasi API Amazon Rekognition Image dengan menggunakan file yang dimuat dari sistem file lokal. Anda meneruskan byte gambar ke operasi Amazon Rekognition API dengan [menggunakan](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_Image.html) parameter input Image. Dalam `Image`, Anda menentukan properti `Bytes` untuk meneruskan bit citra yang dikodekan base64.

Bit citra diteruskan ke operasi API Amazon Rekognition dengan menggunakan parameter input `Bytes` yang harus dikodekan ke base64. AWS SDKs yang digunakan contoh ini secara otomatis mengkodekan gambar base64. Anda tidak perlu mengodekan bit citra sebelum memanggil operasi API Amazon Rekognition. Untuk informasi selengkapnya, lihat [Spesifikasi citra](images-information.md). 

Dalam contoh permintaan JSON ini untuk `DetectLabels`, bit citra sumber diteruskan dalam parameter input `Bytes`. 

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

Contoh berikut menggunakan berbagai AWS SDKs dan AWS CLI untuk memanggil`DetectLabels`. Untuk informasi tentang respons operasi `DetectLabels`, lihat [DetectLabels respon](labels-detect-labels-image.md#detectlabels-response).

Untuk JavaScript contoh sisi klien, lihat. [Menggunakan JavaScript](image-bytes-javascript.md)

**Untuk mendeteksi label dalam citra lokal**

1. Jika belum:

   1. Buat atau perbarui pengguna dengan `AmazonRekognitionFullAccess` dan `AmazonS3ReadOnlyAccess` izin. Untuk informasi selengkapnya, lihat [Langkah 1: Siapkan akun AWS dan buat Pengguna](setting-up.md#setting-up-iam).

   1. Instal dan konfigurasikan AWS CLI dan AWS SDKs. Untuk informasi selengkapnya, lihat [Langkah 2: Mengatur AWS CLI dan AWS SDKs](setup-awscli-sdk.md).

1. Gunakan contoh berikut untuk memanggil operasi `DetectLabels`.

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

   Contoh Java berikut menunjukkan cara memuat citra dari sistem file lokal dan mendeteksi label dengan menggunakan operasi AWS SDK [detectLabels](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/rekognition/model/DetectLabelsRequest.html). Ubah nilai `photo` ke nama jalur dan file dari file citra (format .jpg atau .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 ]

   Contoh [AWS SDK for Python](https://aws.amazon.com/sdk-for-python/) berikut menunjukkan cara untuk memuat citra dari sistem file lokal dan memanggil operasi [detect\$1labels](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rekognition.html#Rekognition.Client.detect_labels). Ubah nilai `photo` ke nama jalur dan file dari file citra (format .jpg atau .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 ]

   Contoh berikut menunjukkan cara untuk memuat citra dari sistem file lokal dan mendeteksi label dengan menggunakan operasi `DetectLabels`. Ubah nilai `photo` ke nama jalur dan file dari file citra (format .jpg atau .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 ]

   Contoh [AWS SDK for](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/welcome.html#getting-started) PHP berikut menunjukkan cara memuat gambar dari sistem file lokal dan memanggil operasi [DetectFaces](https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#detectfaces)API. Ubah nilai `photo` ke nama jalur dan file dari file citra (format .jpg atau .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 ]

   Contoh ini menampilkan daftar label yang terdeteksi pada citra input. Ubah nilai `photo` ke nama jalur dan file dari file citra (format .jpg atau .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 ]

   Kode ini diambil dari GitHub repositori contoh SDK AWS Dokumentasi. Lihat contoh lengkapnya [di sini](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);
           }
       }
   }
   ```

------

# Menggunakan JavaScript
<a name="image-bytes-javascript"></a>

Contoh JavaScript halaman web berikut memungkinkan pengguna untuk memilih gambar dan melihat perkiraan usia wajah yang terdeteksi dalam gambar. Perkiraan usia dikembalikan oleh panggilan ke [DetectFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html). 

Gambar yang dipilih dimuat dengan menggunakan JavaScript `FileReader.readAsDataURL` fungsi, yang base64-menyandikan gambar. Hal ini berguna untuk menampilkan citra pada kanvas HTML. Namun, itu berarti bit citra harus tidak dikodekan sebelum mereka diteruskan ke operasi Amazon Rekognition Image. Contoh ini menunjukkan cara tidak mengodekan bit citra yang dimuat. Jika bit citra yang dikodekan tidak berguna bagi Anda, gunakan `FileReader.readAsArrayBuffer` sebagai gantinya karena citra yang dimuat tidak dikodekan. Ini berarti bahwa operasi Amazon Rekognition Image dapat dipanggil tanpa mengodekan bit citra terlebih dahulu. Sebagai contoh, lihat [Menggunakan readAsArray Buffer](#image-bytes-javascript-unencoded).

**Untuk menjalankan JavaScript contoh**

1. Muat kode sumber contoh ke editor.

1. Dapatkan pengenal kolam identitas Amazon Cognito. Untuk informasi selengkapnya, lihat [Mencari pengenal kolam identitas Amazon Cognito](#image-bytes-javascript-auth).

1. Di fungsi `AnonLog` dari kode contoh, ubah `IdentityPoolIdToUse` dan `RegionToUse` dengan nilai-nilai yang Anda catat di langkah 9 dari [Mencari pengenal kolam identitas Amazon Cognito](#image-bytes-javascript-auth). 

1. Di fungsi `DetectFaces`, ubah `RegionToUse` dengan nilai yang Anda gunakan di langkah sebelumnya.

1. Simpan kode sumber contoh sebagai file `.html`.

1. Muat file ke peramban Anda.

1. Pilih tombol **Cari...**, dan pilih citra yang berisi satu wajah atau lebih. Tabel yang ditampilkan berisi perkiraan usia untuk setiap wajah yang terdeteksi dalam citra. 

**catatan**  
Contoh kode berikut menggunakan dua skrip yang tidak lagi menjadi bagian dari Amazon Cognito. Untuk mendapatkan file-file ini, ikuti tautan [ aws-cognito-sdkuntuk.min.js [ amazon-cognito-identitydan.min.js](https://raw.githubusercontent.com/aws/amazon-cognito-identity-js/master/dist/amazon-cognito-identity.min.js)](https://raw.githubusercontent.com/aws/amazon-cognito-identity-js/master/dist/aws-cognito-sdk.js), lalu simpan teks dari masing-masing sebagai file terpisah. `.js` 

## JavaScript kode contoh
<a name="image-bytes-javascript-code"></a>

Contoh kode berikut menggunakan JavaScript V2. Untuk contoh di JavaScript V3, lihat [contoh di repositori contoh SDK AWS Dokumentasi](https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javascriptv3/example_code/rekognition/estimate-age-example/src). GitHub 

```
<!--
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>
```

### Menggunakan readAsArray Buffer
<a name="image-bytes-javascript-unencoded"></a>

Cuplikan kode berikut adalah implementasi alternatif dari `ProcessImage` fungsi dalam kode sampel, menggunakan JavaScript V2. Ini menggunakan `readAsArrayBuffer` untuk memuat citra dan memanggil `DetectFaces`. Karena `readAsArrayBuffer` tidak mengodekan file yang dimuat ke base64, tidak perlu membatalkan pengodean bit citra sebelum memanggil operasi Amazon Rekognition 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.)

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);
  }
```

## Mencari pengenal kolam identitas Amazon Cognito
<a name="image-bytes-javascript-auth"></a>

Agar sederhana, contoh menggunakan kolam identitas Amazon Cognito anonim untuk menyediakan akses tanpa autentikasi ke API Amazon Rekognition Image. Mungkin cocok untuk kebutuhan Anda. Misalnya, Anda dapat menggunakan akses tidak sah untuk memberikan akses gratis, atau uji coba, akses ke situs web Anda sebelum pengguna mendaftar. Untuk memberikan akses yang diautentikasi, gunakan kolam pengguna Amazon Cognito. Untuk informasi selengkapnya, lihat [Kolam Pengguna Amazon Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html). 

Prosedur berikut menunjukkan cara membuat kolam identitas yang memungkinkan akses ke identitas tidak terautentikasi, dan cara untuk mendapatkan pengenal kolam identitas yang diperlukan dalam kode contoh.

**Untuk mendapatkan pengenal kolam identitas**

1. Buka Amazon Cognito [konsol](https://console.aws.amazon.com/cognito/federated).

1. Pilih **Buat kolam identitas baru**.

1. Untuk **Nama kolam identitas\$1**, ketikkan nama untuk kolam identitas Anda.

1. Di **Identitas tidak terautentikasi**, pilih **Aktifkan akses ke identitas yang tidak terautentikasi**.

1. Pilih **Buat kolam**.

1. Pilih **Lihat detail**, dan perhatikan nama peran untuk identitas yang tidak terautentikasi.

1. Pilih **Izinkan**.

1. Di **Platform**, pilih **JavaScript**.

1. Di **Cari Kredensial AWS**, perhatikan nilai-nilai `AWS.config.region` dan `IdentityPooldId` yang ditunjukkan di potongan kode.

1. Buka konsol IAM di [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/).

1. Di panel navigasi, pilih **Peran**.

1. Pilih nama peran yang Anda catat di langkah 6.

1. Di tab **Izin**, pilih **Lampirkan Kebijakan**.

1. Pilih **AmazonRekognitionReadOnlyAccess**.

1. Pilih **Pasang Kebijakan**.