This little setup enables you to log the time stamps of every visitor coming at your door, with the help of the Android application you can easily get that information plus you will be notified immediately with a sound if there is a visitor on your door.
The setup is great if you stay out of home for hours then try this to log the visitors and get the image of the most recent visitor.
To start all you will be needing:- Raspberry Pi with a webcam or Picam
- Internet connectivity on your Pi
- Android phone
- Wifi module (if you don't prefer Ethernet)
We will be needing only two libraries here in order to run the whole setup:
- OpenCV (for face detection)
- Tornado Web Server
The very first step will be installing opencv
. You can follow my opencv
installation tutorial here.
Its okay to have any other version but make sure it has the basic functionality.
Part 2: Installing TornadoThe final library which we will be installing is the Tornado webserver for Python. Log in to your Raspberry pi and Enter the following commands:
sudo apt-get update
This will update your pi (takes some time):
sudo apt-get install python-pip
Install pip:
pip install tornado
This will install the library. If you are facing any difficulty regarding the installation then take a look at there website here. Now we are ready to move towards the code.
Setting up the codeOverviewThe code for this project is quite simple, first it captures an image and detects faces. It will write the information in a text file of how many faces were detected in that particular image and with the time stamp of the image it will log the data for the client. Meanwhile it will store the recent visitor image in the folder too. at every second it does the same thing (you can change the interval in the code).
Creating directories and placing the scriptsFirst create a folder in your Raspberry pi and name it visitor_project in your home directory.
sudo mkdir ~/visitor_project
Then create a new file and name it main.py:
sudo nano ~/visitor_project/main.py
Then open this link and Copy the code into this file from main.py. OR if you prefer git then use the following command:
git clone https://github.com/Anas-siddiqui/Visitor_project.git
This will directly create a new directory in your home and place all the files with code.
Running the codeBefore running the code make sure you know the IP Address of your Raspberry Pi in order to connect. You can find it at your router's page. Execute this:
sudo python ~/visitor_project/main.py
This will start the code, you will get all the alerts on the screen now. To exit or stop press Ctrl+C.
- If there is an error at any point feel free to comment
- Get the apk from the repository folder (Android apk) and install it in your phone
- Make sure your phone is connected to the same network in which Raspberry Pi is connected and the code is running on Pi
- Start the application and press the settings icon on the top right
- Enter the IP address of your Raspberry Pi there
- Then navigate back and start the service
- If successfully connected, Pi will show Client connected and now you can get use all the functions of application
- Make sure the libraries are installed successfully
- If you get an error regarding capture, make sure to set the camera code accordingly (Webcam or picam) discussed above
- Make sure the IP Address set in the Android application is correct
- The project works better if you have a better camera, I recommend you to try changing the interval in the code too so you might get better results
This project can be extended by using face recognizer to recognize known people and making a separate notification for them e.g: Bob was here at some time-stamp. I have done this already but the results are little sub-optimal.
Feel free to ask anything!
Comments
Please log in or sign up to comment.