GithubHelp home page GithubHelp logo

mattgmg1990 / raspberrypi_security_cam Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 168 KB

A collection of scripts for running an intelligent security camera using a Raspberry Pi with an attached camera.

License: Apache License 2.0

Shell 18.15% Python 81.85%

raspberrypi_security_cam's Introduction

Raspberry Pi Security Camera

A collection of scripts for running an intelligent security camera using a Raspberry Pi with an attached camera.

Uses the Motion open source application to monitor the video feed from the camera and detect motion.

The camera will be running as long as the system is up. I have configured motion following this guide to store several still shots and a very short avi movie when motion is detected.

How To Use

Image Cleanup Script

In my Raspberry Pi, I am only using an 8GB SD card, so I don't want to store very many images. I will be emailing/uploading them to a remote server when motion is detected, so I plan to clear the store of images and videos once per day.

To do this, edit cleanup_images_dir.sh to configure the following:

OUTPUT_LOCATION: The absolute path of the directory where motion outputs the image files to clean up. STALE_LIMIT: The amount of time, in minutes, for which any files with a modified date that is older will be deleted.

I am running this as a chron task once per day, to make sure I don't fill up my SD card with images.

Email yourself when something moves!

In motion, you can configure a command to run whenever motion is detected with the on_motion_detected option in motion.config. I set this to trigger email_on_motion.py whenever something moves.

email_on_motion.py will send an email to the addresses you configure that includes an attachment of the most recent still snapshot captured by the camera. If you configure motion to store images while motion is detected, you can be alerted with a still image of the subject immediately when it happens!

To configure email_on_motion.py, just set the following constants in the file:

MOTION_OUTPUT_DIRECTORY: The directory where motion is outputting images.

SMTP_SERVER: The email server that will be sending the outgoing emails. (String)

FROM_ADDRESS: The email address you will send the messages from. (String)

TO_ADDRESSES: A list of email addresses to send the email message to (List of Strings)

USERNAME: The username for the email server that will send the emails (String)

PASSWORD: The password for the email server (String)

In motion.conf (I have published mine as an example), just configure on_motion_detected to trigger the script. Adding "gap 10" after will delay 10 seconds before sending the email (ensuring the image has been captured and saved):

on_motion_detected /home/pi/raspberrypi_security_cam/email_on_motion.py gap 10

Just make sure to set the script to be executable:

chmod +x /home/pi/raspberrypi_security_cam/email_on_motion.py

raspberrypi_security_cam's People

Contributors

mattgmg1990 avatar

Stargazers

Tracy Qi Dong avatar Girish Sonawane avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.