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

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

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: [-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/


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.

You can’t perform that action at this time.