Processing images with Amazon Rekognition — Part I

Amazon Rekognition is a a cloud based Image processing service offered as part of the Amazon Web Services (AWS) suite of services. Image processing is a radical way to handle and use information.

Here is a sample project that I worked on to help get started.

Process labels of an image

Here is the input image sent to Rekognition.

Input image. (image courtesy — https://www.pexels.com)

And this is what Rekognition has found about the image.

******** Labels for audi.jpg
Label: Automobile , Confidence : 97.39591
Label: Car , Confidence : 97.39591
Label: Coupe , Confidence : 97.39591
Label: Sports Car , Confidence : 97.39591
Label: Transportation , Confidence : 97.39591
Label: Vehicle , Confidence : 97.39591

Highlights

Using Rekognition (or services similar to it) provides organizations a way to process images and gather more information that were hitherto not available/possible.

For example a car company can tag its images by category without manual intervention. The possibilities are endless.

This technology is still in its infancy and I believe organizations will come up with creative use cases suit their needs.

The basics

Amazon Rekognition is a service to process images. It uses advanced machine learning & deep learning to process images. By calling this service we can identify labels, faces, etc from an image. All the user needs for this is an AWS account and some basic knowledge to setup an AWS credential.

Prerequisites

A developer needs access to AWS and basic knowledge of using AWS to run this project.

Source code

AWS provides SDKs in different languages (Python, Java, etc) for Rekognition. I prefer using the Java SDK because of familiarity with Java.

Here is a very basic walk-through. The first step involves creating a Rekognition Client. This client needs credentials and the AWS region to reach the service.

AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.standard().withRegion(Regions.US_WEST_2)
 .withCredentials(new AWSStaticCredentialsProvider(credentials)).build();

Create a DetectLabels request. This request object has the image file contents as bytes and the confidence level.

DetectLabelsRequest request = new DetectLabelsRequest().withImage(new Image().withBytes(bytes))
 .withMaxLabels(10).withMinConfidence(75F);

Then send the request and get back the labels.

DetectLabelsResult result = rekognitionClient.detectLabels(request);
 List<Label> labels = result.getLabels();

The code is in GitHub. https://github.com/shankarps/AWSRekognition.

Thanks for reading. Contact me if you need more info.