Skip to content
Detect motion and cat faces with OpenCV 😺 πŸ”Ž
Branch: master
Clone or download
Latest commit 65a8ce8 May 19, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE.md
README.md
agent.py
catscan.py
cloudformation.yml
deploy-lambda.sh
haarcascade_frontalcatface_extended.xml Add cat face detection lambda code Nov 23, 2016
requirements.txt Initial. Add raspberry pi agent Nov 6, 2016

README.md

catscanface 😺

Detect motion and cat faces with Raspberry Pi, OpenCV & AWS Lambda

Thug cat detected with OpenCV

Contains Raspberry Pi agent for uploading motion detected frames to S3 which triggers a Python lambda function for doing further cat Haar Cascade facial processing.

Makes optional use of Datadog for statsd metrics & Raspberry Pi Sense Hat.

Blog post

http://timatooth.com/development/2017/01/01/raspberry-pi-motion-detection-aws-lambda-opencv.html

Raspberry Pi Agent usage

Configuration can be set on the command line or via environment variables. Usage of S3 requires AWS client ID & secrets to be configured.

usage: agent.py [-h] [--resolution RESOLUTION] [--fps FPS]
                [--delta-threshold DELTA_THRESHOLD] [--min-area MIN_AREA]
                [--enable-sensehat] [--enable-statsd] [--enable-annotate]
                [--image-path IMAGE_PATH] [--enable-s3]
                [--s3-bucket S3_BUCKET] [--s3-prefix S3_PREFIX]

Motion detect and upload frames to S3

optional arguments:
  -h, --help            show this help message and exit
  --resolution RESOLUTION
                        e.g 640x480
  --fps FPS             Framerate e.g: 18
  --delta-threshold DELTA_THRESHOLD
  --min-area MIN_AREA
  --enable-sensehat     Use Sense Hat display
  --enable-statsd       Send metrics
  --enable-annotate     Draw detected regions to image
  --image-path IMAGE_PATH
                        Where to save images locally eg /tmp
  --enable-s3           Enable saving frames to AWS S3
  --s3-bucket S3_BUCKET
                        AWS S3 bucket to save frames
  --s3-prefix S3_PREFIX
                        AWS S3 bucket prefix path e.g cats/

Requirements

OpenCV on Raspberry Pi

apt-get install libopencv-dev python-opencv python-dev

pip dependencies for AWS & Datadog

pip install boto3 dogstatsd

AWS Lambda Function for Cat Haar-Cascade facial detection:

CloudFormation Stack

aws cloudformation create-stack --stack-name catscanface --template-body file://cloudformation.yaml --capabilities CAPABILITY_IAM --parameters ParameterKey=S3BucketName,ParameterValue=timatooth

Lambda Deployment

This will download OpenCV compiled on Amazon Linux and update the AWS Lambda function code.

./deploy-lambda.sh
You can’t perform that action at this time.