Project 1: Event Driven Image Detection

Photographer.png

In this project, I will be implementing an Image Detection 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 the vehicle license plate number will be detected and put into a DynamoDB table. In effect, we are simulating how toll roads would capture a license plate number.

Architecture

Architecture Rekognition.png

Infrastructure

  • To quickly create/release the S3 Bucket and DynamoDB table I created this Cloudformation template.
  • CloudFormation template, Lambda function and IAM role can be found here:

    Event Driven Image Detection

Lambda function

The Lambda Function is created with Python

  • Triggered via object creation in S3

  • Utilizes an IAM role with Amazon Rekognition, S3, DynamoDB and Cloudwatch Log permissions.

Lambda IAM Role

The Lambda Function will need an IAM role that allows:

  • Writing logs/creating log streams to CloudWatch

  • Call Amazon Rekognition Detect Text API

  • Get objects from S3 bucket

  • Read/write/update to DynamoDB

  • Execute queries on DynamoDB

Testing Lambda Function

  • The Lambda Function will invoke upon uploading the image to S3

  • Armed with a test image from Google

  • Upload an image to S3 to invoke the lambda function:

licenseplatetest1.jpg

upload test image.png

  • After uploading is complete

    • Check the CloudWatch logs to determine if the text was found:

Filter-log-group-2.png

  • Lambda Function detected the license plate text and logged it in the log stream.

Found-Text-log-stream-3.png

Check 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.

    • Exclude results under 99% confidence:

DynamoDb-Entry-3.png

Conclusion

This project was a great learning experience in CloudFormation, CloudWatch Logs, DynamoDB, Amazon Rekognition and Lambda. I thoroughly enjoyed working on this project and look to evolve this architecture in the future.

To allow users to upload to the S3 bucket, create pre-signed URLs to give users access to the S3 bucket.