如何使用AWS Rekognition一次匹配多个面



我正在使用face Rekognition PHP SDK将自拍人脸与相册照片进行匹配。

为此,我正在浏览用户自拍循环并逐一检查。大约需要15分钟才能得出结果。

这里是我执行的代码片段。

<?php
foreach ( $user_bio_selfies as $selfi ) {
$selfi_path = $user_selfi_path . $selfi['image'];
if ( file_exists( $selfi_path ) ) {
$binary_target_face_image = file_get_contents($selfi_path);
try {
$compareFaces = array(
'QualityFilter' => 'HIGH',
'SimilarityThreshold' => 70,
'SourceImage' => array(
'Bytes' => $binary_source_face_image,
),
'TargetImage' => array(
'Bytes' => $binary_target_face_image,
),
);
$result = $this->client->compareFaces($compareFaces);
$response = $result->toArray();
if ( !empty( $response['FaceMatches'] ) ) {
$matched_face = number_format($response['FaceMatches'][0]['Face']['Confidence'],  2, '.', '');

if ( $matched_face >= 30 ) {
$matched_images[] = array(
'image' => base_url(USER_IMAGE_SITE_PATH) . $selfi['image'],
'confidence' => $matched_face,
);
}
}
} catch (Exception $e) { }
}
}

有没有办法在AWS Rekognition中一次将自拍与一堆图片相匹配?

compareFaces()方法"将输入图像中的人脸与目标输出图像中检测到的100个最大人脸中的每一个进行比较">

此操作中最慢的部分是上传图像进行比较。

创建人脸集合会更快,您可以在其中提供多个图像来创建人脸的"集合"。然后,您可以使用searchFacesByImage():

对于给定的输入图像,首先检测图像中最大的人脸,然后在指定的集合中搜索匹配的人脸。该操作将输入面的特征与指定集合中的面进行比较。

因此,您只需要提供一个图像,它就会将该人脸与已存储在集合中的人脸进行比较。

我建议观看一些AWS Reinvent视频来了解Rekognition:

  • AWS re:Invent 2018:[REAT 1]深入亚马逊Rekognition,ft.Pinterest(AIM307-R1(-YouTube
  • AWS re:Invent 2018:[重复]深入亚马逊Rekognition,ft.Tinder&英国新闻(AIM307-R(-YouTube

最新更新