Smart door opening via Raspberry Pi using face recognition.
This project provides software and hardware installation instructions for smart doors. The software is designed to run on a Raspberry Pi, which is an inexpensive ARM-based computer.
- Raspberry Pi (In my case it is Raspberry Pi B+)
- Micro USB charger (1.5A preferable) for power supply your Raspberry Pi
- Micro SD Card
- Starter Kit V3.0 for Raspberry Pi
- Electro-Magnetic Lock
- Raspberry Pi Camera Night Vision
- Relay 5V 10A/250VAC for lock
- Power supply 12V / 1A for power supply your lock. The end of the cable is not important because it must be cut off anyway.
- Raspberry Pi tape - camera 200cm
- Magnetic sensor to open Door
Step 1:
Documentation of hardware settings in preparation...
- Green led = 5
- Red led = 4
- Yellow led = 26
- Buzzer = 17
- pinBtn = 13
- LockDoor = 6
- Sensor of opening door = 19
- LCD Screen:
- D7 = 18
- RS = 27
- E = 22
- D6 = 23
- D5 = 24
- D4 = 25
-
Install Rasbian onto your Raspberry Pi
-
Activate VNC on Raspberry Pi to operate the device remotely via a computer, not via HDMI [Recommend RealVNC]
-
Activate the camera on Raspberry Pi in raspi-config [More info]
-
Install OpenCv 3 [Tutorial].
Remember to select Python 3 when configuring your virtual environment
-
I recommends run the command "source" each time you open up a new terminal to ensure your system variables have been set up correctly.
source ~/.profile
-
Next, let's enter on virtual environment:
workon cv
Remember to always work on this project in a virtual environment, otherwise the program will not work without OpenCv
-
Add camera drivers
bcm2835-v4l2
to the last line by opening filesudo nano /etc/modules file
-
Install PIL library
pip install pillow
-
Install module to control Raspberry Pi GPIO channels
pip install RPi.GPIO
-
Install progress bar library
pip install progress
-
Now you can enjoy with that project :)
-
Run file 1_face_management.py. This program allows you to manage a list of users based on which faces are recognized.
-
To perform an action, you must enter the listing number. The menu displays:
- Add user: You enter the nickname of the user, the number of samples you want to give him, and then take pictures of the face.
- Add sample for user: This will add the specified number of photos to an existing user.
- Delete user: This can remove a specific user from your list.
- Show list of users: This shows id, nicknames and the number of samples for each user
- Run trainer: Every time you want your changes (adding a user, adding samples or deleting a user) to be taken into account when recognizing faces, you must use a trainer.
- Quit program
After each, adding a user or samples or removing a user, the program asks if you want to use a trainer. If you plan to do several activities, I recommend that you leave it at the very end, because with a large number of samples it takes a while.
-
To be able to run FaceRecognizer at all you have to add at least one user and run trainer. I recommend that you add at least 200/300 samples for proper operation.
- Run 2_face_recognition.py and enjoy the magic of the smart door
- The program in the terminal will show a list of available users who can open the door.
- From now on you can open your door with your face :)
- Add voice control
- Door control using HomeKit (Especially it's about controlling the application over the phone)
- Controlling the system from outside the home.
If you have any doubts or questions, write to my e-mail: kubencki@gmail.com