Using AWS Rekognition to Identify People in CCTV footage
Awhile back now I started adding IP cameras around various points of my house. It began as a way to quickly check if I had left the garage door up (I’m prone to doing that) and just grew from there.
I use an old Mac mini and a fantastic piece of software called Security Spy to manage all the cameras. The only issue is that even after adjusting the sensitivity and the capture areas I still get a ton of false positive alerts. By that, I mean notifications of motion with no people in the image.
This year at Re: Invent during Andy Jassy’s keynote he announced a new service called AWS Artificial Intelligence. The service consists of several solutions including Lex, Polly, Machine Learning and Rekognition.
All the services in AI seem cool, but I immediately had an idea with Amazon Rekognition. I figured that I could use it to reduce the number of emails I was receiving with leaves blowing in the wind or a squirrel running around my backyard.
See below for a high-level overview of what I managed to piece together this weekend.
Security Spy and AWS Rekognition
Here’s a quick overview of how the non-AWS services work.
- Security Spy: Manages the cameras and captures images when motion is detected.
- Synology DS416: Used as my home NAS. Security spy uploads images via FTP to a directory. The Synology device uploads images to an S3 bucket I created.
Once an image is stored in the S3 bucket, I use an S3 Event Notification on Put actions to trigger a simple Lambda function. The Lambda function is written in Python using Boto3 and calls the detect_labels method.
I parse the response and if Rekognition has a confidence of more than 99% that a person is present in the image it generates a Slack notification.