

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Analisi di un'immagine caricata da un file system locale
<a name="images-bytes"></a>

Immagini Amazon Rekognition è in grado di analizzare le immagini fornite come byte di immagini o immagini memorizzate in un bucket Amazon S3.

Questi argomenti forniscono esempi relativi all'invio di byte di immagine alle operazioni API di Immagini Amazon Rekognition utilizzando un file caricato da un file system locale. È possibile trasmettere byte di immagine a un'operazione API di Immagini Amazon Rekognition utilizzando il parametro di input [Image](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_Image.html). In `Image`, è necessario specificare la proprietà `Bytes` per trasmettere i byte di immagine codificati con Base64.

I byte di immagine trasmessi a un'operazione API Amazon Rekognition utilizzando il parametro di input `Bytes` devono essere codificati in formato Base64. L'AWS SDKs che questi esempi utilizzano automaticamente le immagini con codifica in base64. Non è necessario codificare i byte di immagine prima di chiamare un'operazione API Amazon Rekognition. Per ulteriori informazioni, consulta [Specifiche dell'immagine](images-information.md). 

In questa richiesta JSON di esempio per `DetectLabels`, i byte di immagine di origine vengono trasmessi nel parametro di input `Bytes`. 

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

I seguenti esempi utilizzano various AWS SDKs and the to call. AWS CLI `DetectLabels` Per informazioni sulla risposta dell'operazione `DetectLabels`, consulta [DetectLabels - risposta](labels-detect-labels-image.md#detectlabels-response).

Per un JavaScript esempio sul lato client, vedere. [Usando JavaScript](image-bytes-javascript.md)

**Per rilevare le etichette in un'immagine locale**

1. Se non lo hai già fatto:

   1. Crea o aggiorna un utente con le autorizzazioni `AmazonRekognitionFullAccess` e `AmazonS3ReadOnlyAccess`. Per ulteriori informazioni, consulta [Fase 1: impostazione di un account AWS e creazione di un utente](setting-up.md#setting-up-iam).

   1. Installa e configura il AWS CLI e il. AWS SDKs Per ulteriori informazioni, consulta [Passaggio 2: configura AWS CLI e AWS SDKs](setup-awscli-sdk.md).

1. Utilizzare i seguenti esempi per richiamare l'operazione `DetectLabels`.

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

   L'esempio Java seguente mostra come caricare un'immagine dal file system locale e rilevare le etichette utilizzando l'operazione [detectLabels](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/rekognition/model/DetectLabelsRequest.html) dell'SDK AWS. Modifica il valore di `photo` con il percorso e il nome di un file immagine in formato .jpg o .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 ]

   Il seguente esempio [SDK AWS per Python](https://aws.amazon.com/sdk-for-python/) mostra come caricare un'immagine dal file system locale e richiamare l'operazione [detect\$1labels](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rekognition.html#Rekognition.Client.detect_labels). Modifica il valore di `photo` con il percorso e il nome di un file immagine in formato .jpg o .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 ]

   Il seguente esempio di Java mostra come caricare un'immagine dal file system locale e rilevare le etichette utilizzando l'operazione `DetectLabels`. Modifica il valore di `photo` con il percorso e il nome di un file immagine in formato .jpg o .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 ]

   Il seguente esempio di [AWS SDK for](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/welcome.html#getting-started) PHP mostra come caricare un'immagine dal file system locale e [DetectFaces](https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#detectfaces)richiamare l'operazione dell'API. Modifica il valore di `photo` con il percorso e il nome di un file immagine in formato .jpg o .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 ]

   Questo esempio mostra un elenco di etichette rilevate nell'immagine di input. Modifica il valore di `photo` con il percorso e il nome di un file immagine in formato .jpg o .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 ]

   Questo codice è tratto dal repository degli esempi di AWS Documentation SDK. GitHub Guarda l'esempio completo [qui](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);
           }
       }
   }
   ```

------

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

Il seguente esempio di JavaScript pagina Web consente a un utente di scegliere un'immagine e visualizzare le età stimate dei volti rilevati nell'immagine. Le età stimate vengono restituite da una chiamata a [DetectFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html). 

L'immagine scelta viene caricata utilizzando la JavaScript `FileReader.readAsDataURL` funzione, che codifica l'immagine in base64. Questo è utile per visualizzare l'immagine su un canvas HTML. Significa però che i byte dell'immagine non devono essere codificati prima di essere passati a un'operazione Immagini Amazon Rekognition. Questo esempio illustra come non codificare i byte dell'immagine caricata. Se i byte dell'immagine codificata non sono utili, utilizza `FileReader.readAsArrayBuffer` perché l'immagine caricata non è codificata. Ciò significa che le operazioni Immagini Amazon Rekognition possono essere chiamate senza prima decodificare i byte dell'immagine. Per vedere un esempio, consulta [Utilizzo di readAsArray Buffer](#image-bytes-javascript-unencoded).

**Per eseguire l'esempio JavaScript**

1. Carica il codice sorgente dell'esempio in un editor.

1. Scarica l'identificatore Amazon Cognito del pool di identità. Per ulteriori informazioni, consulta [Scarica l'identificatore Amazon Cognito del pool di identità](#image-bytes-javascript-auth).

1. Nella funzione `AnonLog` del codice di esempio, modifica `IdentityPoolIdToUse` e `RegionToUse` nei valori indicati nella fase 9 di [Scarica l'identificatore Amazon Cognito del pool di identità](#image-bytes-javascript-auth). 

1. Nella funzione `DetectFaces`, modifica `RegionToUse` con il valore utilizzato nella fase precedente.

1. Salva il codice sorgente di esempio come un file `.html`.

1. Carica il file nel tuo browser.

1. Seleziona il pulsante **Cerca…**, quindi scegli un'immagine che contenga uno o più volti. Viene visualizzata una tabella che contiene le età stimate per ogni faccia rilevata nell'immagine. 

**Nota**  
L'esempio di codice seguente utilizza due script che non fanno più parte di Amazon Cognito. Per ottenere questi file, segui i collegamenti per [ aws-cognito-sdk.min.js e [ amazon-cognito-identity.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), quindi salva il testo di ciascuno di essi come file separati. `.js` 

## JavaScript codice di esempio
<a name="image-bytes-javascript-code"></a>

Il seguente esempio di codice utilizza JavaScript V2. Per un esempio in JavaScript V3, vedi [l'esempio nel repository degli esempi di AWS Documentation SDK](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>
```

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

Il seguente frammento di codice è un'implementazione alternativa della `ProcessImage` funzione nel codice di esempio, utilizzando V2. JavaScript Viene utilizzato `readAsArrayBuffer` per caricare un'immagine ed effettuare la chiamata a `DetectFaces`. Poiché `readAsArrayBuffer` non utilizza la codifica Base64 per il file caricato, non è necessario decodificare i byte dell'immagine prima di chiamare un'operazione Immagini 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);
  }
```

## Scarica l'identificatore Amazon Cognito del pool di identità
<a name="image-bytes-javascript-auth"></a>

Per semplicità, l'esempio utilizza un pool di identità Amazon Cognito anonimo per fornire un accesso non autenticato all'API Immagini Amazon Rekognition. Questo potrebbe essere idoneo per le tue esigenze. Ad esempio, puoi utilizzare l'accesso non autenticato per fornire il periodo di prova o l'accesso gratuito a un sito Web, prima che gli utenti effettuino la registrazione. Per fornire l'accesso autenticato, utilizza un pool di utenti Amazon Cognito. Per ulteriori informazioni, consulta [il pool di utenti Amazon Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html). 

La procedura seguente mostra come creare un pool di identità che consente l'accesso a identità non autenticate e ottenere l'identificatore del pool di identità necessario per il codice di esempio.

**Per scaricare l'identificatore del pool di identità**

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

1. Scegli **Create new identity pool** (Crea un nuovo pool di identità).

1. Digita un nome per il tuo pool di identità in **Identity pool name\$1** (Nome pool di identità).

1. In **Unauthenticated identites (Identità non autenticate)**, seleziona **Enable access to unauthenticated identities (Abilita l'accesso a identità non autenticate)**.

1. Seleziona **Create Pool** (Crea pool).

1. Scegli **View Details** (Visualizza dettagli) e annota il nome del ruolo per le identità non autenticate.

1. Scegli **Permetti**.

1. In **Piattaforma, scegli**. **JavaScript**

1. In **Ottieni credenziali AWS**, prendere nota dei valori di `AWS.config.region` e `IdentityPooldId` che sono visualizzati nello snippet di codice.

1. Aprire la console IAM all'indirizzo [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/).

1. Nel riquadro di navigazione, seleziona **Ruoli**.

1. Scegli il nome del ruolo annotato nella fase 6.

1. Nella scheda **Permissions (Autorizzazioni)**, scegliere **Attach policies (Collega policy)**.

1. Scegli **AmazonRekognitionReadOnlyAccess**.

1. Scegli **Attach Policy (Collega policy)**.