

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 检测文本
<a name="text-detection"></a>

Amazon Rekognition 可以检测图像和视频中的文本。然后，它会将检测到的文本转换为机器可读的文本。您可以使用图像中的机器可读文本检测来实施一些解决方案，例如：
+ 可视化搜索。例如，检索和显示包含相同文本的图像。
+ 内容见解。例如，提供对文本中出现的主题的见解，该文本是在提取的视频帧中识别的。您的应用程序可以搜索识别的文本中的相关内容，例如新闻、体育赛事比分、运动员号码和字幕。
+ 导航。例如，为视障人士开发可识别餐厅、商店或路标中的名称的支持语音的移动应用程序。
+ 公共安全和交通运输支持。例如，从路况摄像头图像中检测车牌号码。
+ 过滤。例如，从图像中过滤掉个人身份信息 (PII)。

对于视频中的文本检测，您可以实施一些解决方案，例如：
+ 在视频中搜索包含特定文本关键字的剪辑，例如，新闻节目中图片上的来宾姓名。
+ 通过检测意外文本、亵渎性词汇或垃圾邮件，审核内容是否符合组织标准。
+ 查找视频时间线上的所有文本叠加以进行进一步处理，例如替换文本为另一种语言的文本以实现内容国际化。
+ 查找文本位置，以便其他图形能够相应地对齐。

要检测 JPEG 或 PNG 格式图像中的文本，请使用[DetectText](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectText.html)操作。要异步检测视频中的文本，请使用[StartTextDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartTextDetection.html)和[GetTextDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetTextDetection.html)操作。图像和视频文本检测操作支持大多数字体，包括高度风格化的字体。在检测文本后，Amazon Rekognition 将创建检测到的单词和文本行的表示形式，显示它们之间的关系，并告知您文本在图像或视频帧中的位置。

`DetectText` 和 `GetTextDetection` 操作可以检测单词和行。*单词* 是一个或多个不用空格分隔的字母字符。`DetectText` 可以在一张图片中检测多达 100 个单词。`GetTextDetection` 每帧视频还可以检测多达 100 个单词。

单词是一个或多个字母字符，不用空格分隔。Amazon Rekognition 旨在检测英语、阿拉伯语、俄语、德语、法语、意大利语、葡萄牙语和西班牙语的单词。

*行* 是一个由等间距单词组成的字符串。一行不一定是一个完整的句子（句号不表示一行的结尾）。例如，Amazon Rekognition 将一个驾照号码检测为一行。当后面没有对齐的文本或单词之间有较大的间距（相对于单词的长度）时，一行便结束了。根据单词之间的间距，Amazon Rekognition 可能在向同一方向对齐的文本中检测到多个行。如果一个句子跨多个行，则操作将返回多个行。

请考虑以下图像。

![\[咖啡杯带有笑脸和文本“It's Monday but keep smiling”，带有边界框和提取的文本。\]](http://docs.aws.amazon.com/zh_cn/rekognition/latest/dg/images/text.png)


蓝色框表示有关 `DetectText` 操作返回的检测到的文本和该文本的位置的信息。在此示例中，Amazon Rekognition 将“IT's”、“MONDAY”、“but”、“keep”和“Smiling”作为单词检测。Amazon Rekognition 将“IT's”、“MONDAY”、“but keep”和“Smiling”检测为一行。文本必须在横轴的 \$1/- 90 度方向以内才能被检测到。

有关示例，请参阅[检测图像中的文本](text-detecting-text-procedure.md)。

**Topics**
+ [检测图像中的文本](text-detecting-text-procedure.md)
+ [检测存储视频中的文本](text-detecting-video-procedure.md)

# 检测图像中的文本
<a name="text-detecting-text-procedure"></a>

您可以提供输入图像作为图像字节数组（base64 编码的图像字节）或 Amazon S3 对象。在此过程中，您将 JPEG 或 PNG 图像上传到您的 S3 存储桶并指定文件名称。

**检测图像中的文本 (API)**

1. 如果您尚未完成，请完成以下先决条件。

   1. 使用 `AmazonRekognitionFullAccess` 和 `AmazonS3ReadOnlyAccess` 权限创建或更新用户。有关更多信息，请参阅 [步骤 1：设置 AWS 账户并创建用户](setting-up.md#setting-up-iam)。

   1. 安装并配置 AWS Command Line Interface 和 AWS SDKs。有关更多信息，请参阅 [第 2 步：设置 AWS CLI 和 AWS SDKs](setup-awscli-sdk.md)。

1. 将包含文本的图像上传到您的 S3 存储桶。

   有关说明，请参阅**《Amazon Simple Storage Service 用户指南》中的[将对象上传到 Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UploadingObjectsintoAmazonS3.html)。

1. 使用以下示例调用 `DetectText` 操作。

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

   以下示例代码显示在图像中检测到的行和单词。

   将`amzn-s3-demo-bucket`和`photo`的值替换为您在步骤 2 中使用的 S3 存储桶和图像的名称。

   ```
   //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.AmazonRekognitionException;
   import com.amazonaws.services.rekognition.model.Image;
   import com.amazonaws.services.rekognition.model.S3Object;
   import com.amazonaws.services.rekognition.model.DetectTextRequest;
   import com.amazonaws.services.rekognition.model.DetectTextResult;
   import com.amazonaws.services.rekognition.model.TextDetection;
   import java.util.List;
   
   
   
   public class DetectText {
   
      public static void main(String[] args) throws Exception {
         
     
         String photo = "inputtext.jpg";
         String bucket = "bucket";
   
         AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient();
   
        
         
         DetectTextRequest request = new DetectTextRequest()
                 .withImage(new Image()
                 .withS3Object(new S3Object()
                 .withName(photo)
                 .withBucket(bucket)));
       
   
         try {
            DetectTextResult result = rekognitionClient.detectText(request);
            List<TextDetection> textDetections = result.getTextDetections();
   
            System.out.println("Detected lines and words for " + photo);
            for (TextDetection text: textDetections) {
         
                    System.out.println("Detected: " + text.getDetectedText());
                    System.out.println("Confidence: " + text.getConfidence().toString());
                    System.out.println("Id : " + text.getId());
                    System.out.println("Parent Id: " + text.getParentId());
                    System.out.println("Type: " + text.getType());
                    System.out.println();
            }
         } catch(AmazonRekognitionException e) {
            e.printStackTrace();
         }
      }
   }
   ```

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

   此代码取自 AWS 文档 SDK 示例 GitHub 存储库。请在[此处](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/rekognition/src/main/java/com/example/rekognition/DetectText.java)查看完整示例。

   ```
   /**
   *  To run this code example, ensure that you perform the Prerequisites as stated in the Amazon Rekognition Guide:
   *  https://docs.aws.amazon.com/rekognition/latest/dg/video-analyzing-with-sqs.html
   *
   * Also, ensure that set up your development environment, including your credentials.
   *
   * For information, see this documentation topic:
   *
   * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
   */
   
   //snippet-start:[rekognition.java2.detect_text.import]
   import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
   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.DetectTextRequest;
   import software.amazon.awssdk.services.rekognition.model.Image;
   import software.amazon.awssdk.services.rekognition.model.DetectTextResponse;
   import software.amazon.awssdk.services.rekognition.model.TextDetection;
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   import java.io.FileInputStream;
   import java.io.FileNotFoundException;
   import java.io.InputStream;
   import java.util.List;
   //snippet-end:[rekognition.java2.detect_text.import]
   
   /**
   * 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 DetectTextImage {
   
    public static void main(String[] args) {
   
        final String usage = "\n" +
            "Usage: " +
            "   <sourceImage>\n\n" +
            "Where:\n" +
            "   sourceImage - The path to the image that contains text (for example, C:\\AWS\\pic1.png). \n\n";
   
      if (args.length != 1) {
            System.out.println(usage);
            System.exit(1);
        }
   
        String sourceImage = args[0] ;
        Region region = Region.US_WEST_2;
        RekognitionClient rekClient = RekognitionClient.builder()
            .region(region)
            .credentialsProvider(ProfileCredentialsProvider.create("default"))
            .build();
   
        detectTextLabels(rekClient, sourceImage );
        rekClient.close();
    }
   
    // snippet-start:[rekognition.java2.detect_text.main]
    public static void detectTextLabels(RekognitionClient rekClient, String sourceImage) {
   
        try {
            InputStream sourceStream = new FileInputStream(sourceImage);
            SdkBytes sourceBytes = SdkBytes.fromInputStream(sourceStream);
            Image souImage = Image.builder()
                .bytes(sourceBytes)
                .build();
   
            DetectTextRequest textRequest = DetectTextRequest.builder()
                .image(souImage)
                .build();
   
            DetectTextResponse textResponse = rekClient.detectText(textRequest);
            List<TextDetection> textCollection = textResponse.textDetections();
            System.out.println("Detected lines and words");
            for (TextDetection text: textCollection) {
                System.out.println("Detected: " + text.detectedText());
                System.out.println("Confidence: " + text.confidence().toString());
                System.out.println("Id : " + text.id());
                System.out.println("Parent Id: " + text.parentId());
                System.out.println("Type: " + text.type());
                System.out.println();
            }
   
        } catch (RekognitionException | FileNotFoundException e) {
            System.out.println(e.getMessage());
            System.exit(1);
        }
    }
    // snippet-end:[rekognition.java2.detect_text.main]
   ```

------
#### [ AWS CLI ]

   此 AWS CLI 命令显示 `detect-text` CLI 操作的 JSON 输出。

   将`amzn-s3-demo-bucket`和`Name`的值替换为您在步骤 2 中使用的 S3 存储桶和图像的名称。

   将`profile_name`的值替换为您的开发人员资料的名称。

   ```
   aws rekognition detect-text  --image "{"S3Object":{"Bucket":"amzn-s3-demo-bucket","Name":"image-name"}}" --profile default
   ```

   如果您在 Windows 设备上访问 CLI，请使用双引号代替单引号，并用反斜杠（即 \$1）对内部双引号进行转义，以解决可能遇到的任何解析器错误。例如，请参阅以下内容：

   ```
   aws rekognition detect-text  --image "{\"S3Object\":{\"Bucket\":\"amzn-s3-demo-bucket\",\"Name\":\"image-name\"}}" --profile default
   ```

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

   以下示例代码显示在图像中检测到的行和单词。

   将`amzn-s3-demo-bucket`和`photo`的值替换为您在步骤 2 中使用的 S3 存储桶和图像的名称。将创建 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 detect_text(photo, bucket):
   
       session = boto3.Session(profile_name='default')
       client = session.client('rekognition')
   
       response = client.detect_text(Image={'S3Object': {'Bucket': bucket, 'Name': photo}})
   
       textDetections = response['TextDetections']
       print('Detected text\n----------')
       for text in textDetections:
           print('Detected text:' + text['DetectedText'])
           print('Confidence: ' + "{:.2f}".format(text['Confidence']) + "%")
           print('Id: {}'.format(text['Id']))
           if 'ParentId' in text:
               print('Parent Id: {}'.format(text['ParentId']))
           print('Type:' + text['Type'])
           print()
       return len(textDetections)
   
   def main():
       bucket = 'amzn-s3-demo-bucket'
       photo = 'photo-name'
       text_count = detect_text(photo, bucket)
       print("Text detected: " + str(text_count))
   
   if __name__ == "__main__":
       main()
   ```

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

   以下示例代码显示在图像中检测到的行和单词。

   将`amzn-s3-demo-bucket`和`photo`的值替换为您在步骤 2 中使用的 S3 存储桶和图像的名称。

   ```
   //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 DetectText
   {
       public static void Example()
       {
           String photo = "input.jpg";
           String bucket = "amzn-s3-demo-bucket";
   
           AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient();
   
           DetectTextRequest detectTextRequest = new DetectTextRequest()
           {
               Image = new Image()
               {
                   S3Object = new S3Object()
                   {
                       Name = photo,
                       Bucket = bucket
                   }
               }
           };
   
           try
           {
               DetectTextResponse detectTextResponse = rekognitionClient.DetectText(detectTextRequest);
               Console.WriteLine("Detected lines and words for " + photo);
               foreach (TextDetection text in detectTextResponse.TextDetections)
               {
                   Console.WriteLine("Detected: " + text.DetectedText);
                   Console.WriteLine("Confidence: " + text.Confidence);
                   Console.WriteLine("Id : " + text.Id);
                   Console.WriteLine("Parent Id: " + text.ParentId);
                   Console.WriteLine("Type: " + text.Type);
               }
           }
           catch (Exception e)
           {
               Console.WriteLine(e.Message);
           }
       }
   }
   ```

------
#### [ Node.JS ]

   以下示例代码显示在图像中检测到的行和单词。

   将`amzn-s3-demo-bucket`和`photo`的值替换为您在步骤 2 中使用的 S3 存储桶和图像的名称。将`region`的值替换为在您的 .aws 凭证中找到的区域。将创建 Rekognition 会话的行中的`profile_name`值替换为您的开发人员资料的名称。

   ```
   var AWS = require('aws-sdk');
   
   const bucket = 'bucket' // the bucketname without s3://
   const photo  = 'photo' // the name of file
   
   const config = new AWS.Config({
     accessKeyId: process.env.AWS_ACCESS_KEY_ID,
     secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
   }) 
   AWS.config.update({region:'region'});
   const client = new AWS.Rekognition();
   const params = {
     Image: {
       S3Object: {
         Bucket: bucket,
         Name: photo
       },
     },
   }
   client.detectText(params, function(err, response) {
     if (err) {
       console.log(err, err.stack); // handle error if an error occurred
     } else {
       console.log(`Detected Text for: ${photo}`)
       console.log(response)
       response.TextDetections.forEach(label => {
         console.log(`Detected Text: ${label.DetectedText}`),
         console.log(`Type: ${label.Type}`),
         console.log(`ID: ${label.Id}`),
         console.log(`Parent ID: ${label.ParentId}`),
         console.log(`Confidence: ${label.Confidence}`),
         console.log(`Polygon: `)
         console.log(label.Geometry.Polygon)
       } 
       )
     } 
   });
   ```

------

## DetectText 操作请求
<a name="detecttext-request"></a>

在 `DetectText` 操作中，您可将输入图像作为 base64 编码的字节数组提供，也可将其作为 Amazon S3 存储桶中存储的图像提供。以下示例 JSON 请求显示从 Amazon S3 存储桶加载的图像。

```
{
    "Image": {
        "S3Object": {
            "Bucket": "amzn-s3-demo-bucket",
            "Name": "inputtext.jpg"
        }
    }
}
```

### 筛选条件
<a name="text-filters"></a>

通过按文本区域、大小和置信度评分进行筛选，您可以更加灵活地控制文本检测输出。通过使用感兴趣的区域，您可以轻松地将文本检测限制到与您相关的区域，例如，在从机器的图像中读取零件编号时，档案照片的右上角或相对于参考点的固定位置。单词边界框大小筛选器可用于避免噪点或不相关的小背景文本。通过单词置信度筛选器，您可以移除因模糊或脏污导致的不可靠的结果。

有关筛选值的信息，请参阅 `[DetectTextFilters](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectTextFilters.html)`。

您可以使用以下筛选器：
+ **MinConfidence**— 设置字词检测的置信度。从结果中排除检测置信度低于此级别的单词。值应介于 0 和 100 之间。
+ **MinBoundingBoxWidth**— 设置单词边界框的最小宽度。将从结果中排除其边界框小于此值的单词。该值是相对于图像帧宽度的。
+ **MinBoundingBoxHeight**— 设置单词边框的最小高度。将从结果中排除其边界框高度小于此值的单词。该值是相对于图像帧高度的。
+ **RegionsOfInterest**— 将检测范围限制在图像帧的特定区域。这些值是相对于帧的尺寸的。对于仅部分位于区域内的文本，响应是不确定的。

## DetectText 操作响应
<a name="text-response"></a>

该`DetectText`操作分析图像并返回一个数组 TextDetections，其中每个元素 (`[TextDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_TextDetection.html)`) 表示图像中检测到的行或字。对于每个元素，`DetectText` 将返回以下信息：
+ 检测到的文本 (`DetectedText`)
+ 单词与行之间的关系（`Id` 和 `ParentId`）
+ 图像上的文本的位置 (`Geometry`)
+ Amazon Rekognition 对检测到的文本和边界框的准确性的置信度（`Confidence`）
+ 检测到的文本的类型 (`Type`)

### 检测到的文本
<a name="text-detected-text"></a>

每个 `TextDetection` 元素均包含在 `DetectedText` 字段中识别的文本（单词或行）。单词是一个或多个字母字符，不用空格分隔。在一个图像中，`DetectText` 最多可以检测 100 个单词。返回的文本可能包含使单词无法被识别的字符。例如，用 *C@t* 替换 *Cat*。要确定某个 `TextDetection` 元素是表示一行文本还是一个单词，请使用 `Type` 字段。

 

每个 `TextDetection` 元素均包含一个百分比值，表示 Amazon Rekognition 对检测到的文本和文本周围的边界框的准确性的置信度。

### 单词与行的关系
<a name="text-ids"></a>

每个 `TextDetection` 元素都有一个标识符字段 `Id`。`Id` 显示单词在行中的位置。如果元素是单词，父标识符字段 `ParentId` 将标识检测到单词的行。行的 `ParentId` 为 null。例如，示例图中的行“but keep”具有以下 `Id` 和 `ParentId` 值：


|  文本  |  ID  |  父级 ID  | 
| --- | --- | --- | 
|  but keep  |  3  |     | 
|  but  |  8  |  3  | 
|  keep  |  9  |  3  | 

### 文本在图像上的位置
<a name="text-location"></a>

要确定识别的文本在图像上的位置，请使用 `DetectText` 返回的边界框 ([Geometry](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_Geometry.html)) 信息。`Geometry` 对象包含两种类型的边界框信息，分别适用于检测到的行和单词：
+ [BoundingBox](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_BoundingBox.html) 对象中轴对齐的粗糙矩形轮廓线
+ [点](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_Point.html)数组中由多个 X 坐标和 Y 坐标组成的更精细的多边形

边界框和多边形坐标将显示文本在源图像上的位置。坐标值是占图像总体尺寸的比率。有关更多信息，请参阅 [BoundingBox](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_BoundingBox.html)。

来自 `DetectText` 操作的以下 JSON 响应显示了下图中检测到的单词和行。

![\[笑脸咖啡杯旁边的文本写着“It's Monday but keep Smiling”，以砖块为背景，带有文本边界框。\]](http://docs.aws.amazon.com/zh_cn/rekognition/latest/dg/images/text.png)


```
{
 'TextDetections': [{'Confidence': 99.35693359375,
                     'DetectedText': "IT'S",
                     'Geometry': {'BoundingBox': {'Height': 0.09988046437501907,
                                                  'Left': 0.6684935688972473,
                                                  'Top': 0.18226495385169983,
                                                  'Width': 0.1461552083492279},
                                  'Polygon': [{'X': 0.6684935688972473,
                                               'Y': 0.1838926374912262},
                                              {'X': 0.8141663074493408,
                                               'Y': 0.18226495385169983},
                                              {'X': 0.8146487474441528,
                                               'Y': 0.28051772713661194},
                                              {'X': 0.6689760088920593,
                                               'Y': 0.2821454107761383}]},
                     'Id': 0,
                     'Type': 'LINE'},
                    {'Confidence': 99.6207275390625,
                     'DetectedText': 'MONDAY',
                     'Geometry': {'BoundingBox': {'Height': 0.11442459374666214,
                                                  'Left': 0.5566731691360474,
                                                  'Top': 0.3525116443634033,
                                                  'Width': 0.39574965834617615},
                                  'Polygon': [{'X': 0.5566731691360474,
                                               'Y': 0.353712260723114},
                                              {'X': 0.9522717595100403,
                                               'Y': 0.3525116443634033},
                                              {'X': 0.9524227976799011,
                                               'Y': 0.4657355844974518},
                                              {'X': 0.5568241477012634,
                                               'Y': 0.46693623065948486}]},
                     'Id': 1,
                     'Type': 'LINE'},
                    {'Confidence': 99.6160888671875,
                     'DetectedText': 'but keep',
                     'Geometry': {'BoundingBox': {'Height': 0.08314694464206696,
                                                  'Left': 0.6398131847381592,
                                                  'Top': 0.5267938375473022,
                                                  'Width': 0.2021435648202896},
                                  'Polygon': [{'X': 0.640289306640625,
                                               'Y': 0.5267938375473022},
                                              {'X': 0.8419567942619324,
                                               'Y': 0.5295097827911377},
                                              {'X': 0.8414806723594666,
                                               'Y': 0.609940767288208},
                                              {'X': 0.6398131847381592,
                                               'Y': 0.6072247624397278}]},
                     'Id': 2,
                     'Type': 'LINE'},
                    {'Confidence': 88.95134735107422,
                     'DetectedText': 'Smiling',
                     'Geometry': {'BoundingBox': {'Height': 0.4326171875,
                                                  'Left': 0.46289217472076416,
                                                  'Top': 0.5634765625,
                                                  'Width': 0.5371078252792358},
                                  'Polygon': [{'X': 0.46289217472076416,
                                               'Y': 0.5634765625},
                                              {'X': 1.0, 'Y': 0.5634765625},
                                              {'X': 1.0, 'Y': 0.99609375},
                                              {'X': 0.46289217472076416,
                                               'Y': 0.99609375}]},
                     'Id': 3,
                     'Type': 'LINE'},
                    {'Confidence': 99.35693359375,
                     'DetectedText': "IT'S",
                     'Geometry': {'BoundingBox': {'Height': 0.09988046437501907,
                                                  'Left': 0.6684935688972473,
                                                  'Top': 0.18226495385169983,
                                                  'Width': 0.1461552083492279},
                                  'Polygon': [{'X': 0.6684935688972473,
                                               'Y': 0.1838926374912262},
                                              {'X': 0.8141663074493408,
                                               'Y': 0.18226495385169983},
                                              {'X': 0.8146487474441528,
                                               'Y': 0.28051772713661194},
                                              {'X': 0.6689760088920593,
                                               'Y': 0.2821454107761383}]},
                     'Id': 4,
                     'ParentId': 0,
                     'Type': 'WORD'},
                    {'Confidence': 99.6207275390625,
                     'DetectedText': 'MONDAY',
                     'Geometry': {'BoundingBox': {'Height': 0.11442466825246811,
                                                  'Left': 0.5566731691360474,
                                                  'Top': 0.35251158475875854,
                                                  'Width': 0.39574965834617615},
                                  'Polygon': [{'X': 0.5566731691360474,
                                               'Y': 0.3537122905254364},
                                              {'X': 0.9522718787193298,
                                               'Y': 0.35251158475875854},
                                              {'X': 0.9524227976799011,
                                               'Y': 0.4657355546951294},
                                              {'X': 0.5568241477012634,
                                               'Y': 0.46693626046180725}]},
                     'Id': 5,
                     'ParentId': 1,
                     'Type': 'WORD'},
                    {'Confidence': 99.96778869628906,
                     'DetectedText': 'but',
                     'Geometry': {'BoundingBox': {'Height': 0.0625,
                                                  'Left': 0.6402802467346191,
                                                  'Top': 0.5283203125,
                                                  'Width': 0.08027780801057816},
                                  'Polygon': [{'X': 0.6402802467346191,
                                               'Y': 0.5283203125},
                                              {'X': 0.7205580472946167,
                                               'Y': 0.5283203125},
                                              {'X': 0.7205580472946167,
                                               'Y': 0.5908203125},
                                              {'X': 0.6402802467346191,
                                               'Y': 0.5908203125}]},
                     'Id': 6,
                     'ParentId': 2,
                     'Type': 'WORD'},
                    {'Confidence': 99.26438903808594,
                     'DetectedText': 'keep',
                     'Geometry': {'BoundingBox': {'Height': 0.0818721204996109,
                                                  'Left': 0.7344760298728943,
                                                  'Top': 0.5280686020851135,
                                                  'Width': 0.10748066753149033},
                                  'Polygon': [{'X': 0.7349520921707153,
                                               'Y': 0.5280686020851135},
                                              {'X': 0.8419566750526428,
                                               'Y': 0.5295097827911377},
                                              {'X': 0.8414806127548218,
                                               'Y': 0.6099407076835632},
                                              {'X': 0.7344760298728943,
                                               'Y': 0.6084995269775391}]},
                     'Id': 7,
                     'ParentId': 2,
                     'Type': 'WORD'},
                    {'Confidence': 88.95134735107422,
                     'DetectedText': 'Smiling',
                     'Geometry': {'BoundingBox': {'Height': 0.4326171875,
                                                  'Left': 0.46289217472076416,
                                                  'Top': 0.5634765625,
                                                  'Width': 0.5371078252792358},
                                  'Polygon': [{'X': 0.46289217472076416,
                                               'Y': 0.5634765625},
                                              {'X': 1.0, 'Y': 0.5634765625},
                                              {'X': 1.0, 'Y': 0.99609375},
                                              {'X': 0.46289217472076416,
                                               'Y': 0.99609375}]},
                     'Id': 8,
                     'ParentId': 3,
                     'Type': 'WORD'}],
 'TextModelVersion': '3.0'}
```

# 检测存储视频中的文本
<a name="text-detecting-video-procedure"></a>

存储视频中的 Amazon Rekognition Video 文本检测是一个异步操作。要开始检测文本，请致电[StartTextDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartTextDetection.html)。Amazon Rekognition Video 会将视频分析的完成状态发布到 Amazon SNS 主题。如果视频分析成功，请调用 [GetTextDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetTextDetection.html) 来获取分析结果。有关启动视频分析和获取结果的详细信息，请参阅[调用 Amazon Rekognition Video 操作](api-video.md)。

此过程扩展了[使用 Java 或 Python 分析存储在 Amazon S3 存储桶中的视频 (SDK)](video-analyzing-with-sqs.md)中的代码。它使用 Amazon SQS 队列获取视频分析请求的完成状态。

**检测存储在 Amazon S3 存储桶内的视频中的文本 (SDK)**

1. 按照[使用 Java 或 Python 分析存储在 Amazon S3 存储桶中的视频 (SDK)](video-analyzing-with-sqs.md)中的步骤操作。

1. 将以下代码添加到步骤 1 中的 `VideoDetect` 类。

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

   ```
   //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.)
   
   
   private static void StartTextDetection(String bucket, String video) throws Exception{
              
       NotificationChannel channel= new NotificationChannel()
               .withSNSTopicArn(snsTopicArn)
               .withRoleArn(roleArn);
       
       StartTextDetectionRequest req = new StartTextDetectionRequest()
               .withVideo(new Video()
                       .withS3Object(new S3Object()
                           .withBucket(bucket)
                           .withName(video)))
               .withNotificationChannel(channel);
       
       
       StartTextDetectionResult startTextDetectionResult = rek.startTextDetection(req);
       startJobId=startTextDetectionResult.getJobId();
       
   } 
   
   private static void GetTextDetectionResults() throws Exception{
       
       int maxResults=10;
       String paginationToken=null;
       GetTextDetectionResult textDetectionResult=null;
       
       do{
           if (textDetectionResult !=null){
               paginationToken = textDetectionResult.getNextToken();
   
           }
           
       
           textDetectionResult = rek.getTextDetection(new GetTextDetectionRequest()
                .withJobId(startJobId)
                .withNextToken(paginationToken)
                .withMaxResults(maxResults));
       
           VideoMetadata videoMetaData=textDetectionResult.getVideoMetadata();
               
           System.out.println("Format: " + videoMetaData.getFormat());
           System.out.println("Codec: " + videoMetaData.getCodec());
           System.out.println("Duration: " + videoMetaData.getDurationMillis());
           System.out.println("FrameRate: " + videoMetaData.getFrameRate());
               
               
           //Show text, confidence values
           List<TextDetectionResult> textDetections = textDetectionResult.getTextDetections();
   
   
           for (TextDetectionResult text: textDetections) {
               long seconds=text.getTimestamp()/1000;
               System.out.println("Sec: " + Long.toString(seconds) + " ");
               TextDetection detectedText=text.getTextDetection();
               
               System.out.println("Text Detected: " + detectedText.getDetectedText());
                   System.out.println("Confidence: " + detectedText.getConfidence().toString());
                   System.out.println("Id : " + detectedText.getId());
                   System.out.println("Parent Id: " + detectedText.getParentId());
                   System.out.println("Bounding Box" + detectedText.getGeometry().getBoundingBox().toString());
                   System.out.println("Type: " + detectedText.getType());
                   System.out.println();
           }
       } while (textDetectionResult !=null && textDetectionResult.getNextToken() != null);
         
           
   }
   ```

   在函数 `main` 中，将以下行: 

   ```
           StartLabelDetection(amzn-s3-demo-bucket, video);
   
           if (GetSQSMessageSuccess()==true)
           	GetLabelDetectionResults();
   ```

   替换为:

   ```
           StartTextDetection(amzn-s3-demo-bucket, video);
   
           if (GetSQSMessageSuccess()==true)
           	GetTextDetectionResults();
   ```

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

   此代码取自 AWS 文档 SDK 示例 GitHub 存储库。请在[此处](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/rekognition/src/main/java/com/example/rekognition/VideoDetectText.java)查看完整示例。

   ```
   //snippet-start:[rekognition.java2.recognize_video_text.import]
   import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
   import software.amazon.awssdk.regions.Region;
   import software.amazon.awssdk.services.rekognition.RekognitionClient;
   import software.amazon.awssdk.services.rekognition.model.S3Object;
   import software.amazon.awssdk.services.rekognition.model.NotificationChannel;
   import software.amazon.awssdk.services.rekognition.model.Video;
   import software.amazon.awssdk.services.rekognition.model.StartTextDetectionRequest;
   import software.amazon.awssdk.services.rekognition.model.StartTextDetectionResponse;
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   import software.amazon.awssdk.services.rekognition.model.GetTextDetectionResponse;
   import software.amazon.awssdk.services.rekognition.model.GetTextDetectionRequest;
   import software.amazon.awssdk.services.rekognition.model.VideoMetadata;
   import software.amazon.awssdk.services.rekognition.model.TextDetectionResult;
   import java.util.List;
   //snippet-end:[rekognition.java2.recognize_video_text.import]
   
   /**
   * 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 DetectTextVideo {
   
    private static String startJobId ="";
    public static void main(String[] args) {
   
        final String usage = "\n" +
            "Usage: " +
            "   <bucket> <video> <topicArn> <roleArn>\n\n" +
            "Where:\n" +
            "   bucket - The name of the bucket in which the video is located (for example, (for example, amzn-s3-demo-bucket). \n\n"+
            "   video - The name of video (for example, people.mp4). \n\n" +
            "   topicArn - The ARN of the Amazon Simple Notification Service (Amazon SNS) topic. \n\n" +
            "   roleArn - The ARN of the AWS Identity and Access Management (IAM) role to use. \n\n" ;
   
        if (args.length != 4) {
            System.out.println(usage);
            System.exit(1);
        }
   
        String bucket = args[0];
        String video = args[1];
        String topicArn = args[2];
        String roleArn = args[3];
   
        Region region = Region.US_EAST_1;
        RekognitionClient rekClient = RekognitionClient.builder()
            .region(region)
            .credentialsProvider(ProfileCredentialsProvider.create("profile-name"))
            .build();
   
        NotificationChannel channel = NotificationChannel.builder()
            .snsTopicArn(topicArn)
            .roleArn(roleArn)
            .build();
   
        startTextLabels(rekClient, channel, bucket, video);
        GetTextResults(rekClient);
        System.out.println("This example is done!");
        rekClient.close();
    }
   
    // snippet-start:[rekognition.java2.recognize_video_text.main]
    public static void startTextLabels(RekognitionClient rekClient,
                                   NotificationChannel channel,
                                   String bucket,
                                   String video) {
        try {
            S3Object s3Obj = S3Object.builder()
                .bucket(bucket)
                .name(video)
                .build();
   
            Video vidOb = Video.builder()
                .s3Object(s3Obj)
                .build();
   
            StartTextDetectionRequest labelDetectionRequest = StartTextDetectionRequest.builder()
                .jobTag("DetectingLabels")
                .notificationChannel(channel)
                .video(vidOb)
                .build();
   
            StartTextDetectionResponse labelDetectionResponse = rekClient.startTextDetection(labelDetectionRequest);
            startJobId = labelDetectionResponse.jobId();
   
        } catch (RekognitionException e) {
            System.out.println(e.getMessage());
            System.exit(1);
        }
    }
   
    public static void GetTextResults(RekognitionClient rekClient) {
   
        try {
            String paginationToken=null;
            GetTextDetectionResponse textDetectionResponse=null;
            boolean finished = false;
            String status;
            int yy=0 ;
   
            do{
                if (textDetectionResponse !=null)
                    paginationToken = textDetectionResponse.nextToken();
   
                GetTextDetectionRequest recognitionRequest = GetTextDetectionRequest.builder()
                    .jobId(startJobId)
                    .nextToken(paginationToken)
                    .maxResults(10)
                    .build();
   
                // Wait until the job succeeds.
                while (!finished) {
                    textDetectionResponse = rekClient.getTextDetection(recognitionRequest);
                    status = textDetectionResponse.jobStatusAsString();
   
                    if (status.compareTo("SUCCEEDED") == 0)
                        finished = true;
                    else {
                        System.out.println(yy + " status is: " + status);
                        Thread.sleep(1000);
                    }
                    yy++;
                }
   
                finished = false;
   
                // Proceed when the job is done - otherwise VideoMetadata is null.
                VideoMetadata videoMetaData=textDetectionResponse.videoMetadata();
                System.out.println("Format: " + videoMetaData.format());
                System.out.println("Codec: " + videoMetaData.codec());
                System.out.println("Duration: " + videoMetaData.durationMillis());
                System.out.println("FrameRate: " + videoMetaData.frameRate());
                System.out.println("Job");
   
                List<TextDetectionResult> labels= textDetectionResponse.textDetections();
                for (TextDetectionResult detectedText: labels) {
                    System.out.println("Confidence: " + detectedText.textDetection().confidence().toString());
                    System.out.println("Id : " + detectedText.textDetection().id());
                    System.out.println("Parent Id: " + detectedText.textDetection().parentId());
                    System.out.println("Type: " + detectedText.textDetection().type());
                    System.out.println("Text: " + detectedText.textDetection().detectedText());
                    System.out.println();
                }
   
            } while (textDetectionResponse !=null && textDetectionResponse.nextToken() != null);
   
        } catch(RekognitionException | InterruptedException e) {
            System.out.println(e.getMessage());
            System.exit(1);
        }
    }
    // snippet-end:[rekognition.java2.recognize_video_text.main]
   }
   ```

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

   ```
   #Copyright 2019 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.)
   
       def StartTextDetection(self):
           response=self.rek.start_text_detection(Video={'S3Object': {'Bucket': self.bucket, 'Name': self.video}},
               NotificationChannel={'RoleArn': self.roleArn, 'SNSTopicArn': self.snsTopicArn})
   
           self.startJobId=response['JobId']
           print('Start Job Id: ' + self.startJobId)
     
       def GetTextDetectionResults(self):
           maxResults = 10
           paginationToken = ''
           finished = False
   
           while finished == False:
               response = self.rek.get_text_detection(JobId=self.startJobId,
                                               MaxResults=maxResults,
                                               NextToken=paginationToken)
   
               print('Codec: ' + response['VideoMetadata']['Codec'])
               
               print('Duration: ' + str(response['VideoMetadata']['DurationMillis']))
               print('Format: ' + response['VideoMetadata']['Format'])
               print('Frame rate: ' + str(response['VideoMetadata']['FrameRate']))
               print()
   
               for textDetection in response['TextDetections']:
                   text=textDetection['TextDetection']
   
                   print("Timestamp: " + str(textDetection['Timestamp']))
                   print("   Text Detected: " + text['DetectedText'])
                   print("   Confidence: " +  str(text['Confidence']))
                   print ("      Bounding box")
                   print ("        Top: " + str(text['Geometry']['BoundingBox']['Top']))
                   print ("        Left: " + str(text['Geometry']['BoundingBox']['Left']))
                   print ("        Width: " +  str(text['Geometry']['BoundingBox']['Width']))
                   print ("        Height: " +  str(text['Geometry']['BoundingBox']['Height']))
                   print ("   Type: " + str(text['Type']) )
                   print()
   
               if 'NextToken' in response:
                   paginationToken = response['NextToken']
               else:
                   finished = True
   ```

   在函数 `main` 中，将以下行:

   ```
       analyzer.StartLabelDetection()
       if analyzer.GetSQSMessageSuccess()==True:
           analyzer.GetLabelDetectionResults()
   ```

   替换为:

   ```
       analyzer.StartTextDetection()
       if analyzer.GetSQSMessageSuccess()==True:
           analyzer.GetTextDetectionResults()
   ```

------
#### [ CLI ]

   运行以下 AWS CLI 命令开始检测视频中的文本。

   ```
    aws rekognition start-text-detection --video "{"S3Object":{"Bucket":"amzn-s3-demo-bucket","Name":"video-name"}}"\
    --notification-channel "{"SNSTopicArn":"topic-arn","RoleArn":"role-arn"}" \
    --region region-name --profile profile-name
   ```

   更新以下值：
   + 将`amzn-s3-demo-bucket`和`video-name`更改为您在步骤 2 中指定的 Amazon S3 存储桶名称和文件名。
   + 将`region-name`更改为您使用的 AWS 区域。
   + 将`profile-name`的值替换为您的开发人员资料的名称。
   + 将 `topic-ARN` 更改为您在 [配置 Amazon Rekognition Video](api-video-roles.md) 的步骤 3 中创建的 Amazon SNS 主题的 ARN。
   + 将 `role-ARN` 更改为您在 [配置 Amazon Rekognition Video](api-video-roles.md) 的步骤 7 中创建的 IAM 服务角色的 ARN。

   如果您在 Windows 设备上访问 CLI，请使用双引号代替单引号，并用反斜杠（即 \$1）对内部双引号进行转义，以解决可能遇到的任何解析器错误。有关示例，请参阅以下内容：

   ```
   aws rekognition start-text-detection --video \
    "{\"S3Object\":{\"Bucket\":\"amzn-s3-demo-bucket\",\"Name\":\"video-name\"}}" \
    --notification-channel "{\"SNSTopicArn\":\"topic-arn\",\"RoleArn\":\"role-arn\"}" \
    --region region-name --profile profile-name
   ```

   运行后续代码示例后，复制返回的 `jobID` 并将其提供给以下 `GetTextDetection` 命令以获取结果，将 `job-id-number` 替换为您之前收到的 `jobID`：

   ```
   aws rekognition get-text-detection --job-id job-id-number --profile profile-name             
   ```

------
**注意**  
如果您已经运行了除 [使用 Java 或 Python 分析存储在 Amazon S3 存储桶中的视频 (SDK)](video-analyzing-with-sqs.md) 之外的视频示例，则要替换的代码可能会有所不同。

1. 运行该代码。在视频中检测到的文本将显示在列表中。

## 筛选条件
<a name="text-detection-filters"></a>

筛选器是可选的请求参数，可供您在调用 `StartTextDetection` 时使用。通过按文本区域、大小和置信度评分进行筛选，您可以更加灵活地控制文本检测输出。通过使用感兴趣的区域，您可以轻松将文本检测范围限制为相关的区域，例如，图片的倒数第三个区域或者用于显示足球比赛记分板的左上角。单词边界框大小筛选器可用于避免噪点或不相关的小背景文本。最后，通过单词置信度筛选器，您可以移除因模糊或脏污导致的不可靠的结果。

有关筛选值的信息，请参阅 `[DetectTextFilters](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectTextFilters.html)`。

您可以使用以下筛选器：
+ **MinConfidence**— 设置字词检测的置信度。从结果中排除检测置信度低于此级别的单词。值应介于 0 和 100 之间。
+ **MinBoundingBoxWidth**— 设置单词边界框的最小宽度。将从结果中排除其边界框小于此值的单词。该值是相对于视频帧宽度的。
+ **MinBoundingBoxHeight**— 设置单词边框的最小高度。将从结果中排除其边界框高度小于此值的单词。该值是相对于视频帧高度的。
+ **RegionsOfInterest**— 将检测范围限制在帧的特定区域。这些值是相对于帧尺寸的。对于仅部分位于区域内的对象，响应是不确定的。

## GetTextDetection 响应
<a name="text-detecting-video-response"></a>

`GetTextDetection` 将返回一个数组 (`TextDetectionResults`)，其中包含有关在视频中检测到的文本的信息。每当在视频中检测到单词或行时，都会存在一个数组元素 [TextDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_TextDetection.html)。数组元素按时间（从视频开始起计时，以毫秒为单位）进行排序。

以下是来自 `GetTextDetection` 的部分 JSON 响应。在响应中，请注意以下内容：
+ **文本信息**-`TextDetectionResult` 数组元素包含有关检测到的文本 ([TextDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_TextDetection.html)) 和视频中检测到文本的时间 (`Timestamp`) 的信息。
+ **分页信息** – 此示例显示一页文本检测信息。您可以在 `GetTextDetection` 的 `MaxResults` 输入参数中指定要返回的文本元素数量。如果存在的结果的数量超过了 `MaxResults` 或结果数超过默认的最大值，则 `GetTextDetection` 会返回一个令牌 (`NextToken`)，用于获取下一页的结果。有关更多信息，请参阅 [获取 Amazon Rekognition Video 分析结果](api-video.md#api-video-get)。
+ **视频信息** - 此响应包含有关由 `VideoMetadata` 返回的每页信息中的视频格式 (`GetTextDetection`) 的信息。

```
{
    "JobStatus": "SUCCEEDED",
    "VideoMetadata": {
        "Codec": "h264",
        "DurationMillis": 174441,
        "Format": "QuickTime / MOV",
        "FrameRate": 29.970029830932617,
        "FrameHeight": 480,
        "FrameWidth": 854
    },
    "TextDetections": [
        {
            "Timestamp": 967,
            "TextDetection": {
                "DetectedText": "Twinkle Twinkle Little Star",
                "Type": "LINE",
                "Id": 0,
                "Confidence": 99.91780090332031,
                "Geometry": {
                    "BoundingBox": {
                        "Width": 0.8337579369544983,
                        "Height": 0.08365312218666077,
                        "Left": 0.08313830941915512,
                        "Top": 0.4663468301296234
                    },
                    "Polygon": [
                        {
                            "X": 0.08313830941915512,
                            "Y": 0.4663468301296234
                        },
                        {
                            "X": 0.9168962240219116,
                            "Y": 0.4674469828605652
                        },
                        {
                            "X": 0.916861355304718,
                            "Y": 0.5511001348495483
                        },
                        {
                            "X": 0.08310343325138092,
                            "Y": 0.5499999523162842
                        }
                    ]
                }
            }
        },
        {
            "Timestamp": 967,
            "TextDetection": {
                "DetectedText": "Twinkle",
                "Type": "WORD",
                "Id": 1,
                "ParentId": 0,
                "Confidence": 99.98338317871094,
                "Geometry": {
                    "BoundingBox": {
                        "Width": 0.2423887550830841,
                        "Height": 0.0833333358168602,
                        "Left": 0.08313817530870438,
                        "Top": 0.46666666865348816
                    },
                    "Polygon": [
                        {
                            "X": 0.08313817530870438,
                            "Y": 0.46666666865348816
                        },
                        {
                            "X": 0.3255269229412079,
                            "Y": 0.46666666865348816
                        },
                        {
                            "X": 0.3255269229412079,
                            "Y": 0.550000011920929
                        },
                        {
                            "X": 0.08313817530870438,
                            "Y": 0.550000011920929
                        }
                    ]
                }
            }
        },
        {
            "Timestamp": 967,
            "TextDetection": {
                "DetectedText": "Twinkle",
                "Type": "WORD",
                "Id": 2,
                "ParentId": 0,
                "Confidence": 99.982666015625,
                "Geometry": {
                    "BoundingBox": {
                        "Width": 0.2423887550830841,
                        "Height": 0.08124999701976776,
                        "Left": 0.3454332649707794,
                        "Top": 0.46875
                    },
                    "Polygon": [
                        {
                            "X": 0.3454332649707794,
                            "Y": 0.46875
                        },
                        {
                            "X": 0.5878220200538635,
                            "Y": 0.46875
                        },
                        {
                            "X": 0.5878220200538635,
                            "Y": 0.550000011920929
                        },
                        {
                            "X": 0.3454332649707794,
                            "Y": 0.550000011920929
                        }
                    ]
                }
            }
        },
        {
            "Timestamp": 967,
            "TextDetection": {
                "DetectedText": "Little",
                "Type": "WORD",
                "Id": 3,
                "ParentId": 0,
                "Confidence": 99.8787612915039,
                "Geometry": {
                    "BoundingBox": {
                        "Width": 0.16627635061740875,
                        "Height": 0.08124999701976776,
                        "Left": 0.6053864359855652,
                        "Top": 0.46875
                    },
                    "Polygon": [
                        {
                            "X": 0.6053864359855652,
                            "Y": 0.46875
                        },
                        {
                            "X": 0.7716627717018127,
                            "Y": 0.46875
                        },
                        {
                            "X": 0.7716627717018127,
                            "Y": 0.550000011920929
                        },
                        {
                            "X": 0.6053864359855652,
                            "Y": 0.550000011920929
                        }
                    ]
                }
            }
        },
        {
            "Timestamp": 967,
            "TextDetection": {
                "DetectedText": "Star",
                "Type": "WORD",
                "Id": 4,
                "ParentId": 0,
                "Confidence": 99.82640075683594,
                "Geometry": {
                    "BoundingBox": {
                        "Width": 0.12997658550739288,
                        "Height": 0.08124999701976776,
                        "Left": 0.7868852615356445,
                        "Top": 0.46875
                    },
                    "Polygon": [
                        {
                            "X": 0.7868852615356445,
                            "Y": 0.46875
                        },
                        {
                            "X": 0.9168618321418762,
                            "Y": 0.46875
                        },
                        {
                            "X": 0.9168618321418762,
                            "Y": 0.550000011920929
                        },
                        {
                            "X": 0.7868852615356445,
                            "Y": 0.550000011920929
                        }
                    ]
                }
            }
        }
    ],
    "NextToken": "NiHpGbZFnkM/S8kLcukMni15wb05iKtquu/Mwc+Qg1LVlMjjKNOD0Z0GusSPg7TONLe+OZ3P",
    "TextModelVersion": "3.0"
}
```