

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

# Amazon Rekognition 的工作原理
<a name="how-it-works"></a>

Amazon Rekognition 提供了两个 API 集用于视觉分析：
+  Amazon Rekognition Image 用于图像分析 
+  Amazon Rekognition Video 用于视频分析 

**图像分析**

借助 Amazon Rekognition Image，您的应用程序可以：
+ 检测图像中的对象、场景和概念
+ 识别名人
+ 检测多种语言的文本
+ 检测露骨、不当或暴力的内容或图像
+ 检测、分析和比较人脸以及人脸属性，例如年龄和情绪
+ 检测是否佩戴个人防护设备

使用案例包括增强照片应用程序、对图像进行分类以及对内容进行审核。

**视频分析**

借助 Amazon Rekognition Video，您的应用程序可以：
+ 跨视频帧跟踪人物和对象
+ 识别对象
+ 识别名人
+ 搜索存储视频和流视频，寻找相关的人
+ 分析人脸属性，例如年龄和情绪
+ 检测露骨、不当或暴力的内容或图像
+ 按时间戳和分段对分析结果进行汇总和排序
+ 检测流视频中的人物、宠物和包裹

使用案例包括视频分析、对视频进行分类以及筛选不当内容。

**主要特征**
+ 强大的深度学习分析
+ 高精度的对象、场景、人脸、文本检测
+ 可集成到应用程序中的易于使用的 API
+ 根据您的数据调整的可自定义模型
+ 可扩展的媒体库分析



Amazon Rekognition 允许您通过训练自定义适配器来提高其某些深度学习模型的准确性。例如，使用 Amazon Rekognition 自定义审核，您可以通过使用图像训练自定义适配器来调整 Amazon Rekognition 的基础图像分析模型。有关更多信息，请参阅[使用自定义审核提高准确性](https://docs.aws.amazon.com/rekognition/latest/dg/moderation-custom-moderation.html)。

以下章节将介绍 Amazon Rekognition 提供的分析类型，并概述 Amazon Rekognition Image 和 Amazon Rekognition Video 操作。此外，还涵盖非存储操作与存储操作之间的差别。

要演示 Amazon Rekognition，[你可以看到第 3 步：开始使用 AWS CLI 和 AWS SDK API，其中包括在](https://docs.aws.amazon.com/rekognition/latest/dg/get-started-exercise.html)控制台中试用 Rekogniti APIs on。 AWS 

**Topics**
+ [了解 Rekognition 的分析类型](how-it-works-types.md)
+ [了解 Rekognition 的图像和视频操作](how-it-works-operations-intro.md)
+ [了解非存储和存储 API 操作](how-it-works-storage-non-storage.md)
+ [了解模型版本控制](face-detection-model.md)

# 了解 Rekognition 的分析类型
<a name="how-it-works-types"></a>

以下是 Amazon Rekognition Image API 和 Amazon Rekognition Video API 可以执行的分析类型。有关的信息 APIs，请参阅[了解 Rekognition 的图像和视频操作](how-it-works-operations-intro.md)。

下表列出了与正在使用的媒体类型和使用情况相关的需要使用的操作：


****  

| 使用场景 | 媒体类型 | 操作 | 
| --- | --- | --- | 
|  [审核内容](moderation.md)  | 图片 |  [DetectModerationLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectModerationLabels.html), [StartMediaAnalysisJob](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartMediaAnalysisJob.html), [GetMediaAnalysisJob](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetMediaAnalysisJob.html), [ListMediaAnalysisJobs](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_ListMediaAnalysisJobs.html)  | 
|  | 存储视频 |  [StartContentModeration](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartContentModeration.html), [GetContentModeration](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetContentModeration.html)   | 
| 身份验证 | [映像](collections.md) | [CreateCollection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateCollection.html), [CreateUser](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateUser.html), [IndexFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_IndexFaces.html), [AssociateFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_AssociateFaces.html), [SearchFacesByImage](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_SearchFacesByImage.html), [SearchUsersByImage](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_SearchUsersByImage.html) | 
|  | [存储视频](procedure-person-search-videos.md) | [CreateCollection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateCollection.html), [IndexFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_IndexFaces.html), [StartFaceSearch](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartFaceSearch.html), [GetFaceSearch](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetFaceSearch.html) | 
|  | 流视频（[检测人脸活跃度](face-liveness.md)） |  [CreateFaceLivenessSession](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateFaceLivenessSession.html), [StartFaceLivenessSession](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartFaceLivenessSession.html), [GetFaceLivenessSessionResults](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetFaceLivenessSessionResults.html),  | 
| [人脸分析](faces.md) | 图片 | [DetectFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html), [CompareFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CompareFaces.html) | 
|  | 存储视频 | [StartFaceDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartFaceDetection.html), [GetFaceDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetFaceDetection.html) | 
|  | 流视频 | [CreateStreamProcessor](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateStreamProcessor.html), [StartStreamProcessor](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartStreamProcessor.html) | 
| [物体和活动识别](labels.md) | 图片 | [DetectLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectLabels.html) | 
|  | 存储视频 | [StartLabelDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartLabelDetection.html), [GetLabelDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetLabelDetection.html) | 
| [互联家居](https://github.com/aws-samples/rekognition-streaming-video-events) | 流视频 | [StartStreamProcessor](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartStreamProcessor.html) | 
| [媒体分析](segments.md) | 存储视频 | [StartSegmentDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartSegmentDetection.html), [GetSegmentDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetSegmentDetection.html) | 
| [工作场所安全](ppe-detection.md) | 图片 | [DetectProtectiveEquipment](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectProtectiveEquipment.html) | 
| [文本检测](text-detection.md) | 图片 | [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) | 
| [人物的轨迹](persons.md) | 视频 | [StartPersonTracking](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartPersonTracking.html), [GetPersonTracking](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetPersonTracking.html) | 
| [名人识别](celebrities.md) | 图片 | [RecognizeCelebrities](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_RecognizeCelebrities.html) | 
|  | 视频 | [StartCelebrityRecognition](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartCelebrityRecognition.html), [GetCelebrityRecognition](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetCelebrityRecognition.html) | 
| [自定义标签检测](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/what-is.html) | 图片 | [DetectCustomLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectCustomLabels.html) | 
|  | 模型训练 | [参见自定义标签开发人员指南](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/what-is.html) | 

## 标签
<a name="how-it-works-labels-intro"></a>

*标签* 是指以下任一项目：物体（例如，花、树或桌子）、事件（例如，婚礼、毕业典礼或生日聚会）、概念（例如，风景、傍晚和自然）或活动（例如，跑步或打篮球）。Amazon Rekognition 可以检测图像和视频中的标签。有关更多信息，请参阅 [检测对象和概念](labels.md)。

Rekognition 可以检测图像和存储视频中的大量标签。Rekognition 还可以检测流视频中的少量标签。

根据使用案例使用以下操作检测标签：
+ 要检测图像中的标签：使用[DetectLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectLabels.html)。您可以识别图像属性，例如主图像颜色和图像质量。为此，请[DetectLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectLabels.html)使用 wit `IMAGE_PROPERTIES` h 作为输入参数。
+ 要检测存储视频中的标签：使用[StartLabelDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartLabelDetection.html)。存储视频不支持检测主图像颜色和图像质量。
+ 要检测流媒体视频中的标签：使用[CreateStreamProcessor](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateStreamProcessor.html)。流视频不支持检测主图像颜色和图像质量。

您可以使用纳入和排除筛选选项来指定要为图像和存储视频标签检测返回的标签类型。

## 自定义标签
<a name="how-it-works-custom-labels-intro"></a>

Amazon Rekognition Custom Labels 可以通过训练机器学习模型，识别图像中特定于您的业务需求的物体和场景。例如，您可以训练模型来检测徽标或装配线上的工程机器零件。

**注意**  
有关 Amazon Rekognition Custom Labels 的信息，请参阅 [Amazon Rekognition Custom Labels 开发人员指南](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/what-is.html)。

Amazon Rekognition 提供了用于创建、训练、评估和运行机器学习模型的控制台。有关更多信息，请参阅**《Amazon Rekognition Custom Labels 开发人员指南》中的 [Amazon Rekognition Custom Labels 入门](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/gs-introduction.html)。您还可以使用 Amazon Rekognition Custom Labels API 来训练和运行模型。*有关更多信息，请参阅亚马逊 Rekognit [ion 开发者指南中的亚马逊 Rekognition 自定义标签 SDK 入门](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/gs-cli.html)。 CustomLabels *

要使用经过训练的模型分析图像，请使用[DetectCustomLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectCustomLabels.html)。

## 面部活跃度检测
<a name="face-liveness-detection"></a>

Amazon Rekognition Face Liveness 可以帮助您验证正在进行人脸身份验证的用户是否真实出现在摄像头前，并且不是仿冒用户人脸的不法分子。它可以检测出现在摄像头前的仿冒攻击和绕过摄像头的攻击。用户可以通过拍摄简短的自拍视频来完成 Face Liveness 检查，该检查会返回 Liveness 分数。Face Liveness 通过概率计算确定，检查后会返回置信度分数（介于 0-100 之间）。分数越高，对于接受检查的人是真实的就越有信心。

有关 Face Liveness 的更多信息，请参阅[检测人脸活跃度](face-liveness.md)。

## 人脸检测和分析
<a name="how-it-works-faces-intro"></a>

Amazon Rekognition 可以检测图像和存储视频中的人脸。借助 Amazon Rekognition，您可以获得有关以下内容的信息：
+ 在图像或视频中检测到人脸的位置
+ 人脸标记，例如眼睛的位置
+ 图像中存在人脸遮挡
+ 检测到的情绪，例如快乐或悲伤
+ 图像中人物的视线方向

您还可以解读人口统计信息，例如性别或年龄。您可以将一个图像中的人脸与另一个图像中检测到的人脸进行比较。还可以存储有关人脸的信息以供以后检索。有关更多信息，请参阅 [检测和分析人脸](faces.md)。

要检测图像中的人脸，请使用 [DetectFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html)。要检测存储视频中的人脸，请使用 [StartFaceDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartFaceDetection.html)。

## 人脸搜索
<a name="how-it-works-search-faces-intro"></a>

Amazon Rekognition 可以搜索人脸。人脸信息将索引到称为集合的容器中。集合中的人脸信息随后可与在图像、存储视频和流视频中检测到的人脸进行匹配。有关更多信息，请参阅 [在集合中搜索人脸](collections.md)。

要搜索图像中的已知人脸，请使用 [DetectFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html)。要搜索存储视频中的已知人脸，请使用 [StartFaceDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartFaceDetection.html)。要搜索流视频中的已知人脸，请使用 [CreateStreamProcessor](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateStreamProcessor.html)。

## 人物的轨迹
<a name="how-it-works-persons-intro"></a>

Amazon Rekognition 可以跟踪在存储视频中检测到的人物的轨迹。Amazon Rekognition Video 提供了在视频中检测到的人物的跟踪轨迹、人脸详细信息以及帧内位置信息。有关更多信息，请参阅 [人物的轨迹](persons.md)。

要检测所存储视频中的人员，请使用 [StartPersonTracking](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartPersonTracking.html)。

## 个人防护设备
<a name="how-it-works-ppe-intro"></a>

 Amazon Rekognition 可以检测图像中检测到的人员佩戴的个人防护设备 (PPE)。Amazon Rekognition 可以检测口罩、手套和头罩。Amazon Rekognition 可以预测个人防护设备能否覆盖相应的身体部位。您还可以获得用于检测到的人员和个人防护装备物品的边界框。有关更多信息，请参阅 [检测个人防护设备](ppe-detection.md)。

要检测图像中的 PPE，请使用[DetectProtectiveEquipment](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectProtectiveEquipment.html)。

## 名人
<a name="how-it-works-celebrities-intro"></a>

 Amazon Rekognition 可以识别图像和存储视频中的数千位名人。您可以获取有关名人的人脸在图像上的位置、人脸标记以及名人人脸的姿势的信息。您可以获取名人出现在存储视频中时的跟踪信息。您还可以获得有关知名名人的更多信息，例如所表达的情感和性别的表现。有关更多信息，请参阅 [识别名人](celebrities.md)。

要识别图像中的名人，请使用 [RecognizeCelebrities](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_RecognizeCelebrities.html)。要识别存储视频中的名人，请使用 [StartCelebrityRecognition](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartCelebrityRecognition.html)。

## 文本检测
<a name="how-it-works-text-intro"></a>

Amazon Rekognition 图像文本识别可以检测图像中的文本并将其转换为机器可读的文本。有关更多信息，请参阅 [检测文本](text-detection.md)。

要检测图像中的文本，请使用 [DetectText](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectText.html)。

## 不当或冒犯性内容
<a name="how-it-works-moderation-intro"></a>

Amazon Rekognition 可以分析图像和存储视频中是否有成人和暴力内容。有关更多信息，请参阅 [审核内容](moderation.md)。

要检测不安全的图像，请使用 [DetectModerationLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectModerationLabels.html)。要检测不安全的存储视频，请使用 [StartContentModeration](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartContentModeration.html)。

## 自定义
<a name="how-it-works-customization"></a>

Rekognition APIs 提供的某些图像分析允许您通过创建根据自己的数据训练的自定义适配器来提高深度学习模型的准确性。适配器是可插入 Rekognition 预先训练好的深度学习模型的组件，可利用基于图像的领域知识提高模型的准确性。您可以通过提供样本图像并对其进行注释来训练适配器以满足您的需求。

创建适配器后，系统会为您提供一个 AdapterId。您可以将其提供 AdapterId 给操作，以指定要使用已创建的适配器。例如，您可以向 [DetectModerationLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectModerationLabels.html)API 提供用于同步图像分析。 AdapterId 在请求中提供后 AdapterId ，Rekognition 会自动使用它来增强对图像的预测。这使您可以利用 Rekognition 的功能，同时对其进行自定义以满足您的需求。

您还可以选择使用 [StartMediaAnalysisJob](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartMediaAnalysisJob.html)API 批量获取图像的预测结果。有关更多信息，请参阅[批量分析](https://docs.aws.amazon.com/rekognition/latest/dg/bulk-analysis.html)。

您可以通过将图像上传到 Rekognition 控制台并对这些图像进行分析来评测 Rekognition 操作的准确性。Rekognition 将使用所选功能为您的图像添加注释，然后您可以查看预测，使用经过验证的预测来确定哪些标签会从创建适配器中受益。

目前，您可以将适配器与 [DetectModerationLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectModerationLabels.html). 有关创建和使用适配器的更多信息，请参阅[使用自定义审核提高准确性](moderation-custom-moderation.md)。

## 批量分析
<a name="how-it-works-bulk"></a>

Rekognition Bulk Analysis 允许您在执行操作时使用清单文件异步处理大量图像。[StartMediaAnalysisJob](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartMediaAnalysisJob.html)有关更多信息，请参阅[批量分析](https://docs.aws.amazon.com/rekognition/latest/dg/bulk-analysis.html)。

# 了解 Rekognition 的图像和视频操作
<a name="how-it-works-operations-intro"></a>

Amazon Rekognition 提供两个主要 API 集用于进行图像和视频分析：
+ Amazon Rekognition Image：此 API 旨在分析图像。
+ Amazon Rekognition Video：此 API 侧重于分析存储视频和流视频。

两者 APIs 都可以检测各种实体，例如人脸和物体。要全面了解支持的比较和检测类型，请参阅[了解 Rekognition 的分析类型](how-it-works-types.md)中的章节。

## Amazon Rekognition Image 操作
<a name="how-it-works-operations-images"></a>

Amazon Rekognition Image 操作是同步的。输入和响应采用 JSON 格式。Amazon Rekognition Image 操作将分析采用 .jpg 或 .png 图像格式的输入图像。传递到 Amazon Rekognition Image 操作的图像可存储在 Amazon S3 存储桶中。如果您未使用 AWS CLI，则还可以将 Base64 编码图像字节直接传递到 Amazon Rekognition 操作。有关更多信息，请参阅[使用图像](https://docs.aws.amazon.com/rekognition/latest/dg/images.html)。

## Amazon Rekognition Video 操作
<a name="how-it-works-operations-video-intro"></a>

Amazon Rekognition Video API 便于分析存储在 Amazon S3 存储桶中的视频，或通过 Amazon Kinesis Video Streams 流式传输的视频。

对于存储视频操作，请注意以下几点：
+ 操作是异步的。
+ 分析必须通过 “开始” 操作启动（[StartFaceDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartFaceDetection.html)例如，在存储的视频中进行人脸检测）。
+ 分析的完成状态将发布到 Amazon SNS 主题。
+ 要检索分析结果，请使用相应的 “获取” 操作（例如 [GetFaceDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetFaceDetection.html)）。
+ 有关更多信息，请参阅[使用存储视频分析](https://docs.aws.amazon.com/rekognition/latest/dg/video.html)。

对于流视频分析：
+ 功能包括 Rekognition Video 集合中的人脸搜索和标签（对象或概念）检测。
+ 标签分析结果将作为 Amazon SNS 和 Amazon S3 通知发送。
+ 人脸搜索结果将输出到 Kinesis 数据流。
+ 流媒体视频分析的管理是通过 Amazon Rekognition Video 流处理器完成的（例如，使用创建处理器）。[CreateStreamProcessor](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateStreamProcessor.html)
+ 有关更多信息，请参阅[使用流视频事件](https://docs.aws.amazon.com/rekognition/latest/dg/streaming-video.html)。

每个视频分析操作都会返回有关正在分析的视频的元数据，以及任务 ID 和任务标签。标签检测和内容审核等视频操作允许您按时间戳或标签名称进行排序，并按时间戳或分段对结果进行汇总。

## 基于非存储的操作和基于存储的操作
<a name="how-it-works-operations-video-storage"></a>

Amazon Rekognition 操作分为以下类别。
+ **非存储 API 操作** – 在这些操作中，Amazon Rekognition 不保存任何信息。您提供输入图像和视频，操作执行分析，然后返回结果，但 Amazon Rekognition 不会保存任何信息。有关更多信息，请参阅 [非存储操作](how-it-works-storage-non-storage.md#how-it-works-non-storage)。
+ **基于存储的 API 操作** – Amazon Rekognition 服务器可将检测到的人脸信息存储在称为集合的容器中。Amazon Rekognition 提供其他 API 操作，这些操作可用于搜索保存的人脸信息中是否存在匹配的人脸。有关更多信息，请参阅 [基于存储的 API 操作](how-it-works-storage-non-storage.md#how-it-works-storage-based)。

## 使用 AWS 软件开发工具包或 HTTP 调用 Amazon Rekognition API 操作
<a name="images-java-http"></a>

您可以使用 AWS 软件开发工具包调用 Amazon Rekognition API 操作，也可以直接使用 HTTP 调用这些操作。您应总是使用 AWS 软件开发工具包，除非您有充分的理由不这样做。本节中的 Java 示例使用 [AWS 软件开发工具包](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/setup-install.html)。虽然未提供 Java 项目文件，但您可使用 [AWS Toolkit for Eclipse](https://docs.aws.amazon.com/AWSToolkitEclipse/latest/GettingStartedGuide/) 通过 Java 开发 AWS 应用程序。

本节中的 .NET 示例使用 [适用于 .NET 的 AWS SDK](https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/welcome.html)。您可以使用 [AWS Toolkit for Visual Studio](https://docs.aws.amazon.com/AWSToolkitVS/latest/UserGuide/welcome.html) 通过 .NET 开发 AWS 应用程序。它包括有用模板和 AWS 各区服务浏览器，用于部署应用程序和管理服务。

本指南中的 [API 参考](https://docs.aws.amazon.com/rekognition/latest/APIReference/Welcome.html)介绍了使用 HTTP 调用 Amazon Rekognition 操作。有关 Java 参考信息，请参阅 [适用于 Java 的 AWS SDK](https://docs.aws.amazon.com/sdk-for-java/latest/reference/index.html)。

您可使用的 Amazon Rekognition 服务端点记录在 [AWS 区域和端点](https://docs.aws.amazon.com/general/latest/gr/rande.html#rekognition_region)上。

在使用 HTTP 调用 Amazon Rekognition 时，可使用 POST HTTP 操作。

# 了解非存储和存储 API 操作
<a name="how-it-works-storage-non-storage"></a>

Amazon Rekognition 提供了两种类型的 API 操作。即非存储操作和存储操作。对于前者，Amazon Rekognition 不存储任何信息；对于后者，Amazon Rekognition 存储特定人脸信息。

## 非存储操作
<a name="how-it-works-non-storage"></a>

Amazon Rekognition 针对图像提供了以下非存储 API 操作：
+ [DetectLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectLabels.html)
+ [DetectFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html) 
+ [CompareFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CompareFaces.html) 
+ [DetectModerationLabels](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectModerationLabels.html) 
+ [DetectProtectiveEquipment](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectProtectiveEquipment.html) 
+ [RecognizeCelebrities](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_RecognizeCelebrities.html) 
+ [DetectText](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectText.html) 
+ [GetCelebrityInfo](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_GetCelebrityInfo.html) 

Amazon Rekognition 针对视频提供了以下非存储 API 操作：
+ [StartLabelDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartlabelDetection.html) 
+ [StartFaceDetection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartFaceDetection.html) 
+ [StartPersonTracking](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartPersonTracking.html)
+ [StartCelebrityRecognition](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartCelebrityRecognition.html)
+ [StartContentModeration](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartContentModeration.html)

这些操作称作*非存储* API 操作，因为当您进行操作调用时，Amazon Rekognition 不会保留发现的有关输入图像的任何信息。与所有其他 Amazon Rekognition API 操作类似，非存储 API 操作不保留任何输入图像字节。

以下示例方案演示可将非存储 API 操作集成到应用程序中的情况。这些方案假定您有一个本地图像存储库。

**Example 1：一个在包含特定标签的本地存储库中查找图像的应用程序**  
首先，您使用 Amazon Rekognition `DetectLabels` 操作在存储库中的每个图像中检测标签（物体和概念）并建立客户端索引，如下所示：  

```
Label        ImageID

tree          image-1
flower        image-1
mountain      image-1
tulip         image-2
flower        image-2
apple         image-3
```
然后，您的应用程序可以搜索此索引以在本地存储库中查找包含特定标签的图像。例如，显示包含树的图像。  
Amazon Rekognition 检测到的每个标签均有一个关联的置信度值。该值指示包含该标签的输入图像的置信度级别。您可以使用此置信度值选择性地对标签执行其他客户端筛选，具体取决于有关检测中的置信度级别的应用程序要求。例如，如果您需要准确的标签，您可以筛选和选择仅具有更高置信度（例如 95% 或更高）的标签。如果您的应用程序不需要更高的置信度值，您可以选择筛选具有较小置信度值（接近 50%）的标签。

**Example 2：一个用于显示增强的人脸图像的应用程序**  
首先，您可以使用 Amazon Rekognition `DetectFaces` 操作在本地存储库中的每个图像中检测人脸，然后建立客户端索引。对于每个人脸，此操作将返回元数据，其中包含边界框、人脸标记（例如，嘴巴和耳朵的位置）和人脸属性（例如，性别）。您可以在客户端本地索引中存储此元数据，如下所示：  

```
ImageID     FaceID     FaceMetaData

image-1     face-1     <boundingbox>, etc.
image-1     face-2     <boundingbox>, etc.
image-1     face-3     <boundingbox>, etc.
...
```
在此索引中，主键是 `ImageID` 和 `FaceID` 的组合。  
然后，您可以使用索引中的信息，在应用程序从本地存储库显示图像时增强图像。例如，您可以在人脸周围添加边界框或突出显示人脸特征。  
 

## 基于存储的 API 操作
<a name="how-it-works-storage-based"></a>

Amazon Rekognition Image [IndexFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_IndexFaces.html)支持该操作，您可以使用该操作来检测图像中的人脸并保留有关在亚马逊 Rekognition 集合中检测到的面部特征的信息。这是*基于存储的* API 操作的示例，因为服务会将信息保留在服务器上。

Amazon Rekognition Image 提供了以下存储 API 操作：
+ [IndexFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_IndexFaces.html)
+ [ListFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_ListFaces.html) 
+ [SearchFacesByImage](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_SearchFacesByImage.html) 
+ [SearchFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_SearchFaces.html) 
+ [DeleteFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DeleteFaces.html) 
+ [DescribeCollection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DescribeCollection.html) 
+ [DeleteCollection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DeleteCollection.html)
+ [ListCollections](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_ListCollections.html)
+ [CreateCollection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateCollection.html) 

Amazon Rekognition Video 提供了以下存储 API 操作：
+ [StartFaceSearch](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartFaceSearch.html) 
+ [CreateStreamProcessor](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateStreamProcessor.html)

要存储人脸信息，您必须先在账户的一个 AWS 区域中创建一个人脸集合。在调用 `IndexFaces` 操作时指定此人脸集合。在创建人脸集合并存储所有人脸的人脸特征信息后，您可以在集合中搜索匹配的人脸。例如，您可以检测图像中的最大人脸并通过调用 `searchFacesByImage.` 来搜索集合中匹配的人脸。

由 `IndexFaces` 存储在集合中的人脸信息可供 Amazon Rekognition Video 操作访问。例如，您可以通过调用 [StartFaceSearch](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_StartFaceSearch.html) 在视频中搜索其人脸与现有集合中的人脸匹配的人员。

有关创建和管理集合的信息，请参阅[在集合中搜索人脸](collections.md)。

**注意**  
集合存储人脸向量，这些向量是人脸的数学表示。集合不存储人脸图像。

**Example 1：用于对进出大楼进行身份验证的应用程序**  
首先，您应使用 `IndexFaces` 操作来创建一个人脸集合来存储扫描到的徽章图像，此操作将提取人脸并将其存储为可搜索的图像向量。然后，当员工进入大楼时，将捕获员工的人脸图像，并将此图像发送到 `SearchFacesByImage` 操作。如果人脸匹配得到了足够高的相似度得分（例如 99%），则可对员工进行身份验证。

# 了解模型版本控制
<a name="face-detection-model"></a>

Amazon Rekognition 使用深度学习模型来执行人脸检测和搜索集合中的人脸。它根据客户反馈和深度学习研究的进展来提高其模型的准确性。这些改进随模型更新提供。例如，在此模型的 1.0 版本中，[IndexFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_IndexFaces.html) 可以为一个图像中的 15 个最大的人脸编制索引。此模型的较新版本支持 `IndexFaces` 为一个图像中的 100 个最大的人脸编制索引。

当您创建新集合时，它会与此模型的最新版本关联。为了提高准确性，此模型偶尔会更新。

 当发布此模型的新版本时，会发生以下情况：
+ 您创建的新集合与最新模型关联。您使用 [IndexFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_IndexFaces.html) 添加到新集合的人脸通过最新模型来检测。
+ 您的现有集合继续使用创建它们时所使用的模型版本。这些集合中存储的人脸向量不会自动更新到此模型的最新版本。
+ 已添加到现有集合的新人脸可通过已与该集合关联的模型来检测。

此模型的不同版本互相不兼容。具体而言，如果将一个图像索引到使用此模型的不同版本的多个集合，则检测到的同一人脸的人脸标识符是不同的。如果将一个图像索引到与同一模型关联的多个集合，则人脸标识符是相同的。

如果您的集合管理不负责此模型的更新，您的应用程序可能会遇到兼容性问题。您可以通过使用由集合操作（例如 `CreateCollection`）的响应中返回的 `FaceModelVersion` 字段来确定集合使用的模型版本。您可以通过调用 [DescribeCollection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DescribeCollection.html) 获取现有集合的模型版本。有关更多信息，请参阅 [描述集合](describe-collection-procedure.md)。

集合中的现有人脸向量无法更新为此模型的更高版本。由于 Amazon Rekognition 不会存储源图像字节，因此它不会通过使用此模型的更高版本来自动为图像重建索引。

要对存储在现有集合中的人脸使用最新模型，请创建一个新集合 ([CreateCollection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CreateCollection.html)) 并将源图像重新索引到该新集合 (`Indexfaces`) 中。您需要更新由您的应用程序存储的任何人脸标识符，因为新集合中的人脸标识符与旧集合中的人脸标识符是不同的。如果您不再需要旧集合，则可以使用 [DeleteCollection](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DeleteCollection.html) 将其删除。

无状态操作（如 [DetectFaces](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html)）使用最新版本的模型。