Summary
Someone at the university asked for advice on a low cost, âsmartâ security system. He wanted to monitor people entering his dorm room but he didnât want a lot of false alarms since his roommate and friends were often in and out of his room when he wasnât there. The solution â use facial recognition to distinguish between people who are authorized to be there and those who are not. If the person is recognized by the security system, he or she is welcomed into the room; if the person isnât recognized, a photo of the intruder is stored in the system for the room owner to review when he returns.
For this project, I wrote an Universal Windows Platform (UWP) application in C# which runs on Windows 10 IoT Core on a Raspberry Pi 3. I connected a Passive Infrared (PIR) motion sensor to detect when someone enters the room. I included a speech synthesizer and added a speaker to announce that a person has been detected. The attached webcam captures an image of the person and sends it to Microsoft Cognitive Services running on Azure for analysis.
This project was a good introduction to facial recognition and the Microsoft Cognitive Serviceâs Face API made it easier than expected â especially when using their open source SDK. I also resused a lot of the Facial Recognition Door Lock project created by the Windows IoT Team.
Prerequisites
- Youâll need to have Windows 10 (version 10.0.10240 or better) running on your development machine.
- Youâll need the Windows 10 IoT Core Dashboard on your development machine.
- Youâll need to image an SD card with Windows 10 IoT Core â minimum supported OS version for this project is build 10.0.14295.
- Youâll need Visual Studio 2015 Update 2.
Installing all the prerequisites could take up to an hour or so but most of that time is unattended while the bits download and get installed so plan accordingly. Microsoft has documented the setup process well in a step-by-step guide.
With respect to Visual Studio 2015 Update 2, you may need to customize your installation (if you are installing it for the first time) or modify your existing installation to ensure that you have the most recent version of the Window 10 SDK installed â the Windows 10 SDK is not installed by default in the the Community Edition and it is required for this project (I believe it is installed by default in the Professional and Enterprise editions).
To verify that you completed the setup process correctly use the Windows 10 IoT Core Dashboard; the Dashboard will discover the Pi once Windows 10 IoT Core has booted and connected to the network (you can plug a network cable between the Pi and your networkâs router or directly into your development machineâs Ethernet port if you turn on Internet connection sharing).
Use the device portal to configure WiFi. To open the device portal, go to the âMy Devicesâ tab in the Windows 10 IoT Core Dashboard and click on the globe under the âOpen in Device Portal columnâ. Youâll be prompted to enter the credentials for the device â âadministratorâ and âp@ssw0rdâ by default. Go the Networking page to setup WiFi.
Components
The following components are required for this project. In the United States, total component costs are less than $75.
- Raspberry Pi 3 (this project works equally well on the Raspberry Pi 2 but you would then need a separate WiFi dongle if you want to go wireless) (you could also use an Intel MinnowBoard Max or a Qualcomm DragonBoard 410c).
- Passive Infrared Motion Sensor
- Supported webcam (I used the Microsoft LifeCam HD-3000 but others are support as well; check the list here)
- Speaker (plug the speakerâs 3.5mm audio jack directly into theRaspberry Pi; Iâd recommend powering the speak separately)
- Jumper wires
Instructions â Follow these steps
Step 1 â Wire Up the Security System
Time â 5 minutes
The security system is comprised of a PIR sensor, speaker, and webcam connected to a Raspberry Pi 3. The PIR sensor will detect when someone enters your room. The speaker plays the text to speech messages. And, the webcam will capture an image which will be processed by the facial recognition service.
First, connect the PIR motion sensorâs pins to the Raspberry Pi using jumper wires â 5V on the sensor to 5V PWR on the Pi (I used pin 2), GND on the sensor to GND on the Pi (I used pin 6), and signal on the sensor to a GPIO pin on the Pi (I used pin 29 / GPIO 5). Double check the data sheet for your sensor to make sure you correctly identify the sensorâs 5V, GND, and signal pin as their order varies by manufacturer. (I bent the pins on a female header so that I could mount the sensor upright on the mini breadboard.)
My PIR sensor operates at 5 volts which is why itâs power pin needs to be connected to a 5V power pin on the Pi. But, itâs signal pin operates at only 3.3V which is why it can be connected directly to a GPIO pin. Again, double check the data sheet for your sensor to ensure that the signalâs voltage is 3.3V. If itâs 5V, youâll have to divide the voltage before connecting it to the Raspberry Piâs GPIO pin.
For more detail: Facial Recognition Security System