Raspberry Pi Home Security Camera

照片 12-11-17 上午11 09 06.jpg

I purchased a Raspberry Pi 3B & a NOIR Camera last year and I decided to make a home security camera. I installed Raspbian for the Raspberry Pi and OpenCV Library. OpenCV can be used for motion detection & face detection.

My idea is like this: when my Pi detects movement with camera, it captures an image and records the start time of movement. Then it do face detection with the captured image, the image will be saved to the SD card if faces were found. The system will generate a report at the end of the day that summarizes the active period of my room and email it to me together with a few selected photos.
After a week of preparation and testing, I finally made my system working.

1.  Motion Detection. Calculate the absolute difference between previous & current frame for each pixel.

 

motion det_clip.gif

 

2. Save motion detection data.

log data

3.  Detect face & save photo.

2017-07-09 21-00-49

4. Generate Report a the end of the day and send it to me by email.

email snap1.PNG

5. Delete old log & photos to free up space for SD card.

 

Update 2017/09/13

This system has been running for almost 2 months since mid July without error, and the SD card’s free space remains the same as before.  🙂

Update 2017/11/12

Added code to auto generate activity-time chart and send it to me by email at the end of the day. I used matplotlib to generate the chart and save it as PNG image (see example below). This makes the room activity data more user friendly.

ActivityChart 20171104

Thanks for reading 🙂

4 thoughts on “Raspberry Pi Home Security Camera

Leave a comment