searchUsersByImage method
Searches for UserIDs using a supplied image. It first detects the largest face in the image, and then searches a specified collection for matching UserIDs.
The operation returns an array of UserIDs that match the face in the supplied image, ordered by similarity score with the highest similarity first. It also returns a bounding box for the face found in the input image.
Information about faces detected in the supplied image, but not used for
the search, is returned in an array of UnsearchedFace
objects. If no valid face is detected in the image, the response will
contain an empty UserMatches list and no
SearchedFace object.
May throw AccessDeniedException.
May throw ImageTooLargeException.
May throw InternalServerError.
May throw InvalidImageFormatException.
May throw InvalidParameterException.
May throw InvalidS3ObjectException.
May throw ProvisionedThroughputExceededException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
Parameter collectionId :
The ID of an existing collection containing the UserID.
Parameter maxUsers :
Maximum number of UserIDs to return.
Parameter qualityFilter :
A filter that specifies a quality bar for how much filtering is done to
identify faces. Filtered faces aren't searched for in the collection. The
default value is NONE.
Parameter userMatchThreshold :
Specifies the minimum confidence in the UserID match to return. Default
value is 80.
Implementation
Future<SearchUsersByImageResponse> searchUsersByImage({
required String collectionId,
required Image image,
int? maxUsers,
QualityFilter? qualityFilter,
double? userMatchThreshold,
}) async {
_s.validateNumRange(
'maxUsers',
maxUsers,
1,
500,
);
_s.validateNumRange(
'userMatchThreshold',
userMatchThreshold,
0,
100,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'RekognitionService.SearchUsersByImage'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'CollectionId': collectionId,
'Image': image,
if (maxUsers != null) 'MaxUsers': maxUsers,
if (qualityFilter != null) 'QualityFilter': qualityFilter.value,
if (userMatchThreshold != null)
'UserMatchThreshold': userMatchThreshold,
},
);
return SearchUsersByImageResponse.fromJson(jsonResponse.body);
}