startFaceSearch method

Future<StartFaceSearchResponse> startFaceSearch({
  1. required String collectionId,
  2. required Video video,
  3. String? clientRequestToken,
  4. double? faceMatchThreshold,
  5. String? jobTag,
  6. NotificationChannel? notificationChannel,
})

Starts the asynchronous search for faces in a collection that match the faces of persons detected in a stored video.

The video must be stored in an Amazon S3 bucket. Use Video to specify the bucket name and the filename of the video. StartFaceSearch returns a job identifier (JobId) which you use to get the search results once the search has completed. When searching is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in NotificationChannel. To get the search results, first check that the status value published to the Amazon SNS topic is SUCCEEDED. If so, call GetFaceSearch and pass the job identifier (JobId) from the initial call to StartFaceSearch. For more information, see procedure-person-search-videos.

May throw AccessDeniedException. May throw IdempotentParameterMismatchException. May throw InvalidParameterException. May throw InvalidS3ObjectException. May throw InternalServerError. May throw VideoTooLargeException. May throw ProvisionedThroughputExceededException. May throw LimitExceededException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter collectionId : ID of the collection that contains the faces you want to search for.

Parameter video : The video you want to search. The video must be stored in an Amazon S3 bucket.

Parameter clientRequestToken : Idempotent token used to identify the start request. If you use the same token with multiple StartFaceSearch requests, the same JobId is returned. Use ClientRequestToken to prevent the same job from being accidently started more than once.

Parameter faceMatchThreshold : The minimum confidence in the person match to return. For example, don't return any matches where confidence in matches is less than 70%. The default value is 80%.

Parameter jobTag : An identifier you specify that's returned in the completion notification that's published to your Amazon Simple Notification Service topic. For example, you can use JobTag to group related jobs and identify them in the completion notification.

Parameter notificationChannel : The ARN of the Amazon SNS topic to which you want Amazon Rekognition Video to publish the completion status of the search.

Implementation

Future<StartFaceSearchResponse> startFaceSearch({
  required String collectionId,
  required Video video,
  String? clientRequestToken,
  double? faceMatchThreshold,
  String? jobTag,
  NotificationChannel? notificationChannel,
}) async {
  ArgumentError.checkNotNull(collectionId, 'collectionId');
  _s.validateStringLength(
    'collectionId',
    collectionId,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(video, 'video');
  _s.validateStringLength(
    'clientRequestToken',
    clientRequestToken,
    1,
    64,
  );
  _s.validateNumRange(
    'faceMatchThreshold',
    faceMatchThreshold,
    0,
    100,
  );
  _s.validateStringLength(
    'jobTag',
    jobTag,
    1,
    256,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'RekognitionService.StartFaceSearch'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'CollectionId': collectionId,
      'Video': video,
      if (clientRequestToken != null)
        'ClientRequestToken': clientRequestToken,
      if (faceMatchThreshold != null)
        'FaceMatchThreshold': faceMatchThreshold,
      if (jobTag != null) 'JobTag': jobTag,
      if (notificationChannel != null)
        'NotificationChannel': notificationChannel,
    },
  );

  return StartFaceSearchResponse.fromJson(jsonResponse.body);
}