Face Recognition With Raspberry Pi + OpenCV + Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey gang team here at crow electronics and today we're making our raspberry pi recognize who we are by our face [Music] open source software and raspberry pi's go together hand in hand the two excellent examples of this are opencv which provides a huge free resource to solve real-time computer vision problems and the python face recognition package which computes bounding boxes around a face in real time these are the two systems that we will use to make this all come together machine learning has never been more accessible i will show you exactly how to have your raspberry pi microprocessor be able to spot human faces how to train it to know your face and to run code so that it will successfully identify you when it sees you then i'll take it another step and show you how you can use your face to control the servo which is attached to the raspberry pi before me on the table is everything you need to get this system up and running really fast starting off you're going to want a raspberry pi official camera module version 2. you can also use the raspberry pi high quality camera a micro sd card a official raspberry pi power supply a hdmi cord and monitor to connect to a mouse and keyboard and for this i'm using a raspberry pi 4 model b as the extra computing power oomph that the raspberry pi provides is invaluable you're also going to want some way to connect the micro sd card to your computer so you can flash it so we're going to get started with all the packages installed already to follow along at this point go to the article to get the steps to install the packages on your setup once you power up the raspberry pi you're going to see this familiar background booted up now first let's open up the raspberry pi configuration menu found by using the top left menu scrolling over preferences and make sure that the camera found under the interfaces tab is enabled if you had to enable this setting go ahead and reset the raspberry pi so that the changes can take effect now open up the file explorer which is the folder button on the top left of the screen jump into the folder located in the home pi directory facial recognition and then look for the python code called headshots underscore pycam.py this python code will let us take some photos of our faces using the official raspberry pi camera right click and open up that python script with either funny or genie both are just python language interpreter softwares and alter the line of code here with your name in my case timmy then save this script next go back into the folder structure and open up the photos folder here you're going to add another folder with your name this folder is then going to be the location where the photo files will end up then jump back into the python editor where we had saved that python code and run it this will open up a little window and a terminal window which you can use to save images of your face press the spacebar key to take an image take around 10 and then the q key to close the window once you've done so provide a couple of different angles of your face so it can determine your dimensions better once you close the software you're going to be able to see the images of your face stored in the folder you created for your name you can add other faces using this same method too with all that sorted we can get into the machine learning step the pictures we took will now be used by the python code train underscore model dot py any pictures in the dataset folder location will be analyzed by this code when we run this program so open up a new terminal using the black console button on the top left and type the following pressing enter after each line cd space facial underscore recognition this will get us into the right folder and then python space train underscore model dot py which is going to run our desired code this will start the training process which you can see occurring for each image that i took of my face then with that completed the raspberry pi 4 model b will have learned what your face looks like so let's give it a go to run the identification code that will identify faces and when it finds a train face will write their name next to it start by opening up a new terminal just the same as before then type the following and press enter after each step cd facial underscore recognition and then python facial underscore req dot py once you press enter it's going to take around 5 seconds to boot up and run then you're going to see a small window pop up with a live stream of the raspberry pi camera aim the camera at your face and if it puts a yellow box around your head and names you correctly you have done it the raspberry pi camera is now searching live for faces it will also determine if it's a known or an unknown face if it's unknown it's going to write unknown next to it and if it's a face of the name of the person that it knows it's going to write that person's name next to it this example code is awesome and lets you experiment to see when the software can or cannot track your face i find if you tip your head to the side a couple of degrees it's going to completely disable the facial recognition and if you cover your nose as well it struggles close the terminal window or press ctrl c on the keyboard to stop it running [Music] so we can do many things with this now simply to start we can now jump into the folders with the python code and alter just a couple of lines in that code in the facial underscore rec dot py so that every time a known face is seen it's going to send out signals via the gpio pins of the raspberry pi these general purpose input and output pins can be used to control an almost endless amount of sensors and mechanisms so for this i'm going to get a servo to rotate when the raspberry pi system sees my face if it sees an unknown face or no face at all it's not going to activate this servo all this by adding just six lines of code to the script all the code i'll be adding here is completely explained in the guide controlling standard servers with raspberry pi linked down below so hopefully you can see everything what i'm going to do is hide my face from the camera by putting my thumb just in front of it the server you're going to be able to see from the top and when i show up my face you're going to see the server move you can see it's active see down here it's red because my skin is pink and now i'm going to show my face boom straight away as soon as it saw my face nice huge thanks go to the opencv and facial recognition package teams that work on the amazing machine learning software that we have running on this raspberry pi both are really good open source software also a huge thank you goes to carolyn dunn who created the majority of the amazing software which makes these two systems work together so well there's just so much potential with this software to take projects to amazing places so that's it for today until next time stay cozy
Info
Channel: Core Electronics
Views: 176,555
Rating: undefined out of 5
Keywords: face recognition with raspberry pi, identify your face with raspberry pi, face identification with a pi, raspberry pi camera used to identify face, OpenCV and raspberry pi, machine learning raspberry pi, teach a pi your face, How to identify people with raspberry pi, Camera version 2 with raspberry pi, control GPIO Pins with your face, gpio control with biometrics, biometrics, Raspberry pi 4 model b
Id: o-x1PE0LVKM
Channel Id: undefined
Length: 7min 14sec (434 seconds)
Published: Mon Jul 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.