Projects

Event Driven image detection with Amazon Rekognition

In this project I will be implementing an Event Driven architecture based around S3,DynamoDB, Lambda and Amazon Rekognition. Upon uploading an image of a vehicle to S3, the image will be analyzed and vehicle license plate number will be detected and put into a DynamoDB table.

Architecture

Infrastructure

In order to provision and release the infrastructure quickly, I created this Cloudformation template: **The table name, hashkey and range key we will use in this example are: plateindex, vehicle, and filename respectively.

S3 And DynamoDB Table:

Lambda function

The Lambda Function was created with the latest version of Python, triggered via object creation in S3 and utilizes an IAM role with Amazon Rekognition, S3, DynamoDB and Cloudwatch Log permissions.

**Table name, partition key and sort key (plateindex, vehicle, filename) are referenced in the Python code below:

Lambda Role

The Lambda Function will need a policy that allows: writing logs to CloudWatch, call the Amazon Rekognition Detect Text API, read objects from the S3 bucket, read/write to the DynamoDB table and execute queries on the DB table.

Policy will look similar to this:

Testing the Function

The Lambda Function will invoke upon uploading image to S3

  • Armed with our Test image from Google, I'll upload this image to S3 to invoke the lambda function.
  • LicensePlate Uploading
  • After uploading is complete, I'll check the CloudWatch logs to determine if the the text was found..
  • FilterLogGroup
  • Here we can see that the Lambda Function detected the license plate text and logged it in the log stream.
  • Log Stream
  • Checking DynamoDB Entry - The highest entry was for the license plate number; however other results were included such as the state name and month/year of tag expiration. I excluded results under 99% confidence.
  • DynamoDBEntry

    Conclusion

    This project was a great learning experience into CloudFormation, CloudWatch Logs, DynamoDB, Amazon Rekognition and Lambda. I thoroughly enjoyed working on this project and look to evolve this architecture in the future with the addition of: SNS, API Gateway and a website to display the results of the analyzed image.