A fridge "security system" consisting of a Raspberry Pi with a Camera Module which will text the user when Orange Juice has been taken from the fridge by a roommate. This system can be used for any security purpose in any location - not necessarily OJ in the fridge :)
- Install Raspian on a Raspberry Pi. Instructions for doing so can be found here.
- Install Python3, with the PiCamera, dlib and face_recognition modules. Instructions can be found here.
- Connect the Raspberry Pi Camera Module to the Raspberry Pi using the CSI cable. See the image after step 5 for an example.
- Run
sudo raspi-config
and enable the camera in the Interfacing section. - Connect the push-button to the Raspberry Pi's GND and GPIO15 pins as shown in the image below:
- Clone this Git repo.
- Edit the Raspberry Pi crontab with the command
crontab -e
. Add the following line to the crontab:@reboot python3 <path to the main.py file>
. For example, if you cloned the repo into the home directory, the path would be/home/pi/DontTouchMyOJ/main.py
- Generate a Twilio API key from the Twilio website.
- Create a file,
twilio_keys.txt
with the Twilio auth token on the first line and private key on the second. - Generate an Imgur API key from the Imgur API website.
- Create a file,
imgur_keys.txt
with the Twilio auth token on the first line and private key on the second. - Connect the PI to the internet by modifying the
wpa_supplicant.conf
file located in the/etc/
folder. - Replace the pictures of nikhil, with pictures of yourself in the
/encodings/
folder. The default is four images, but if you choose to use more/less, update thenumEncodings
value in thedetectFace.py
script. - Run
python3 generateEncodings.py
to generate the face encodings. - Place the PI as necessary, so that the camera will have a good view of the person, and the object can rest on the button.
- Reboot the Pi and the program should automatically begin.
- The Raspberry Pi will always be locally saving the last 30 seconds of video data.
- If the carton of orange juice is taken from the fridge, face detection will run on the saved video data.
- If the detected face does not match the user's face, a text will be sent to the user, containing an image of the person who took the OJ.
- The image is uploaded to Imgur using the Imgur API.
- Using the Twillo python library, this image is made into a media URL and then the MMS message is sent to the target phone number.
- A push-button is connected to the Raspberry Pi GPIO Pins.
- The output from the push button is read using the PI GPIO library
- The button is placed under the OJ carton when the button is released the output is registered.
- The initial encodings script analysis the facial features present in the images and saves them to a CSV containing the necessary facial features.
- For each of the 30 frames captured, the facial features are captured and compared against each of the face encodings.