detectModerationLabels method

Future<DetectModerationLabelsResponse> detectModerationLabels({
  1. required Image image,
  2. HumanLoopConfig? humanLoopConfig,
  3. double? minConfidence,
})

Detects unsafe content in a specified JPEG or PNG format image. Use DetectModerationLabels to moderate images depending on your requirements. For example, you might want to filter images that contain nudity, but not images containing suggestive content.

To filter images, use the labels returned by DetectModerationLabels to determine which types of content are appropriate.

For information about moderation labels, see Detecting Unsafe Content in the Amazon Rekognition Developer Guide.

You pass the input image either as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file.

May throw InvalidS3ObjectException. May throw InvalidParameterException. May throw ImageTooLargeException. May throw AccessDeniedException. May throw InternalServerError. May throw ThrottlingException. May throw ProvisionedThroughputExceededException. May throw InvalidImageFormatException. May throw HumanLoopQuotaExceededException.

Parameter image : The input image as base64-encoded bytes or an S3 object. If you use the AWS CLI to call Amazon Rekognition operations, passing base64-encoded image bytes is not supported.

If you are using an AWS SDK to call Amazon Rekognition, you might not need to base64-encode image bytes passed using the Bytes field. For more information, see Images in the Amazon Rekognition developer guide.

Parameter humanLoopConfig : Sets up the configuration for human evaluation, including the FlowDefinition the image will be sent to.

Parameter minConfidence : Specifies the minimum confidence level for the labels to return. Amazon Rekognition doesn't return any labels with a confidence level lower than this specified value.

If you don't specify MinConfidence, the operation returns labels with confidence values greater than or equal to 50 percent.

Implementation

Future<DetectModerationLabelsResponse> detectModerationLabels({
  required Image image,
  HumanLoopConfig? humanLoopConfig,
  double? minConfidence,
}) async {
  ArgumentError.checkNotNull(image, 'image');
  _s.validateNumRange(
    'minConfidence',
    minConfidence,
    0,
    100,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'RekognitionService.DetectModerationLabels'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Image': image,
      if (humanLoopConfig != null) 'HumanLoopConfig': humanLoopConfig,
      if (minConfidence != null) 'MinConfidence': minConfidence,
    },
  );

  return DetectModerationLabelsResponse.fromJson(jsonResponse.body);
}