Our project idea is to utilize a Raspberry Pi 3 to build a webcam server that provides a platform for users to remotely monitor their homes over the internet. DropBox uploading of captured images and email notifications will be triggered if a human is detected to warn the user of potential intruders. One usage of this project is to provide a home security system for homeowners while they are physically absent.
The hardware of the system includes a Raspberry Pi 3, a Pi Cam, and a pan-tilt kit with two servos that provides 180 degrees of up/down and left/right rotation. Our final software is based on experimenting with existing OpenCV libraries by using various combinations of motion, face, and human body detection to find the optimal combination of performance versus accuracy for a practical security system.
The objective of this project is to build a human detection security camera system that monitors a home and captures images of potential intruders. The camera mechanism rotates either automatically or manually to track a face when a human is within view of the camera. A notification is sent to the homeowner immediately upon detection of a human to warn the user of the security status of their home.
The Pi Server provides video streaming and runs human face detection and body detection to distingush humans from non-human objects. Notifications are sent to users through email and uploaded to users’ DropBox accounts upon detection.
System Schemetic and Flow Chart Design
The above figures show the design of our system. The servos of the pan-and-tilt kit are connected to 2 GPIO output pins of the Raspberry Pi to enable their control via PWMs. They were powered by an external 4.5V supply, either from a lab bench power supply or a battery pack with a voltage regulator. The Pi Cam was directly connected via the camera slot on the Raspberry Pi’s PCB.
Pan Tilt Servos
Human Detection Algorithm with Opencv
For human body detection, we used existing OpenCV libraries with different combinations of motion, face, and body detection.
Click here for instructions on installing OpenCV3.
Our motion detector uses OpenCV’s APIs to compute the weighted mean of previous frames along with the current frame to detect changes in the background. By subtracting the computed average of the previous frames from the current frame, we can obtain the difference in frames and compare the frame delta with the specified threshold value. If the delta exceeds the threshold, the motion detector is triggered. The lower the threshold value, the more sensitive the motion detector becomes. The video stream on the screen will have a bounding box drawn around the object and text reading “Occupied” when motion is detected.
Human Face Detection
For face detection, we used the Haar cascade classifier as it is capable of significant accuracy detecting human faces. The computational load is also low enough to achieve a reasonable framerate when multithreading on the 4 processing cores of the Raspberry Pi. The Haar cascade face detector already has a classifier trained on human faces, so there is no need for us to perform training.
Click here to download OpenCV Haar cascade classifiers.
Human Body Detection
We worked with two algorithms for human body detection. One is a Haar cascade classifier trained to detect the upper and lower body seperately. The computational load is lower with the Haar cascade at significant expense to accuracy. Thus, we went with the other option and integrated a pedestrian detector that uses a histogram of oriented gradients (HOG) classifier. This algorithm works by detecting different body parts and pieces them together to form a human body. The computation is rather expensive but significantly more accurate than the cascade classifier. (The HOG detector was included in OpenCV with no additional files required for download.)
Dropbox Image Upload of Detected Humans
To trigger the DropBox uploading, users need to have a reigstered DropBox account and save their “dropbox_key” and “dropbox_secret” in the conf.json file (attached in the Appendix section) and consent to DropBox access before running. Once a human is detected, the images will be uploaded automatically into users’ DropBox folders and sent via email if the feature is enabled.
Email Notication of Detected Humans
If a human is detected, an email notification is immediately sent to notify the user of potential intruders. The email notification also includes a captured image of the detected human. The email notification configuration file is attached in the Appendix section.
Install mailutils for email notification
$ sudo apt-get install mailutils
Low cost PCB at PCBWay - only $5 for 10 PCBs and FREE first order for new members
PCB Assembly service starts from $30 with Free shipping all around world + Free stencil
Extra 15% off for flex and rigid-flex PCB