Example usage for com.amazonaws.services.rekognition.model DetectLabelsRequest DetectLabelsRequest

List of usage examples for com.amazonaws.services.rekognition.model DetectLabelsRequest DetectLabelsRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.rekognition.model DetectLabelsRequest DetectLabelsRequest.

Prototype

DetectLabelsRequest

Source Link

Usage

From source file:org.nuxeo.vision.aws.AmazonRekognitionProvider.java

License:Apache License

@Override
public List<VisionResponse> execute(List<Blob> blobs, List<String> features, int maxResults)
        throws IOException, GeneralSecurityException, IllegalStateException {
    List<VisionResponse> result = new ArrayList<>();
    for (Blob blob : blobs) {
        result.add(/*from   w  w  w .  java  2 s .c  om*/
                new AmazonRekognitionResponse(
                        getClient().detectLabels(new DetectLabelsRequest()
                                .withImage(new com.amazonaws.services.rekognition.model.Image()
                                        .withBytes(ByteBuffer.wrap(blob.getByteArray())))
                                .withMaxLabels(maxResults))));
        // different API on AWS Rekognition for safe content detection
        if (features.contains(VisionFeature.SAFE_SEARCH_DETECTION.toString())) {
            result.add(new AmazonRekognitionResponse(
                    getClient().detectModerationLabels(new DetectModerationLabelsRequest()
                            .withImage(new com.amazonaws.services.rekognition.model.Image()
                                    .withBytes(ByteBuffer.wrap(blob.getByteArray()))))));
        }
    }
    return result;
}