Security camera object detection software that runs on a Raspberry Pi.
When a person is detected by the model it sends an email/text notification with a 5 second video clip stored on AWS S3.
ssh
file in the root of the mounted sd card. See Enable SSH on a headless Raspberry Pi (add file to SD card on another machine)wpa_supplicant.conf
file -- see Setting up wireless networking
pi
password: raspberry
-- see Raspberry Pi forum postOn the raspberry pi, git clone
this repo.
$ git clone git@github.com:tleyden/eyepi.git
$ cd eyepi
Install docker engine using the convenience script.
Add the pi user to the docker group:
$ sudo usermod -aG docker pi
$ docker build . -t eyepi
Make sure you can run the docker image:
$ docker run -it --device=/dev/video0:/dev/video0 eyepi eyepi.py --s3bucket eyepi
At this point you should see an error: botocore.exceptions.NoCredentialsError: Unable to locate credentials
since you aren't passing in the AWS creds yet. That's covered in a later step.
Create a new IAM User called "eyepi" and associate S3FullAccess permissions. (TODO: limit permissions)
Create a new bucket with a globally unique name - for example <your-email>-eyepi
, and settings:
Step 1: Allow public access
Step 2: Use the default ACL
Create a new SNS topic called EyePiNotificationsSNS
, and create an email subscription with your email address.
Step 1: Create a new lambda function from the s3 bucket blueprint
Step 2: Set function name and role name to EyepiLambda, choose your eyepi s3 bucket for the s3 trigger
Step 3: Copy the code from lambda-send-sns.py
from this repo into the lambda code text area, and hit the "Create" button
Step 4. Go to the lambda function permission section and click the role
Step 5: Add the AmazonS3ReadOnlyAccess
and AmazonSNSFullAccess
policies
Step 6: In the lambda configuration section, add the SNS ARN as an environment variable called SNS_TOPIC_ARN
First set the boto env variables using the access key and secret key for the IAM user created above (without the {}
's):
$ export AWS_ACCESS_KEY_ID="{your-aws-access-key}"
$ export AWS_SECRET_ACCESS_KEY="{your-secret-key}"
Now launch the docker container
$ docker run -it -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY --device=/dev/video0:/dev/video0 eyepi eyepi.py --s3bucket <your-bucket-name>
You should see output like:
S3 creds OK
read a frame
Frame rate: 1
read a frame
Frame rate: 4.521088120478825
Now walk in front of the camera for a few seconds, and you should see this output:
Person detected!! Capturing video
read a frame
...
Captured frame 6/5
Finished capturing video, returning to IDLE state
Finished capturing video: /tmp/alert_1610002882.726963.avi
Uploading /tmp/alert_1610002882.726963.avi -> eyepi/alert_1610002882.726963.avi ..
Finished uploading /tmp/alert_1610002882.726963.avi -> eyepi/alert_1610002882.726963.avi ..
and you should receive an email alert with subject "EyePi person detected" and text:
person detected with 0.73828125% confidence. Watch captured video: https://
.s3.amazonaws.com/alert_1610002882.726963.avi
Clicking the link on iOS Safari should play it directly.
Kill the docker container previously launched, and re-run and replace the arguments:
-it
with:
-itd
Where the -d
tells docker to daemonize the process. It will show the container id, eg: ce43d7b59c
, and you can view the logs with:
$ docker logs -f ce43d7b59c
Name | Description | Example |
---|---|---|
s3bucket |
The name of the s3 bucket to upload capture videos to | --s3bucket eyepi |
targetobject |
The object to detect | --targetobject mouse |
threshold |
The detection threshold between 0.0 and 1.0 | --threshold 0.72 |
modeldir |
The directory in the container relative to /root where to look for the model. Can be docker volume mount or absolute path. |
--modeldir modeldir |