The project uses face recognition to identify authorized people and opens the door accordingly.
Circuit
We are using 2 devices in this project:
- IR Sensor: The IR sensor provides information if there is an obstacle in front or not. The IR sensor connections are as follows:
- GND Pin connected to GND of the Quarky Expansion Board.
- VCC Pin connected to VCC of the Quarky Expansion Board.
- Signal Pin connected to D3 of the Quarky Expansion Board.
- Servo Motor: The servo motor controls the Door of the IoT house which is connected to the servo port of 5 of the Quarky Expansion Board.
Face Recognition
We will be using Face Detection extension for making the face recognition application.
Working of an IR Sensor
An Infrared sensor is a type of sensor that senses if something is close to it or not. The IR stands for Infrared sensor. Infrared is the light out of our visible spectrum.
An IR sensor has a white LED (transmitter) and a photodiode (receiver). The transmitter emits IR light, and the receiver detects reflected light from objects within the sensor’s range, which can be adjusted with a potentiometer. The sensor is indicated by two LED indicators, a power LED which is always on, and a signal LED which is on when an object is detected and off when nothing is detected.
The signal LED has two states or situations:
- ON (Active) when it detects an object
- OFF (Inactive) when it doesn’t detect any object
Storing the Face Authorised for IoT House
This script allows us to add a new face to the system. First, the video feed from the camera is turned on. Then, the camera is analyzed for a face. If one face has been detected, the user is asked to select a slot (1 to 10) and enter a name for the new face which is then added to the system. Finally, the video feed from the camera is turned off.
Code
This code creates a program that can add a new face to the system, and then recognize and authenticate the user:
- The program sets the threshold for face detection to 0.5, turns off the video feed from the camera, and enables the box to be drawn around the detected face.
- It also moves a servo on the expansion board to position 5 and moves it to 100 degrees to close the door.
- It defines custom blocks called Run Authorization Check.
- The Run Authorization Check block turns on the video feed from the camera, recognizes the face in the camera, and speaks out the name of the recognized user if the face has been recognized. It then returns 1 to indicate the user has been authenticated.
- The program then keeps running the loop forever.
- It also checks if the IR sensor is active and if yes, calls the Run Authorization Check function. If the user has been authenticated, it moves the servo to 0 degrees to open the door and then back to 100 degrees to close the door after some time.