Back to Blog
IntroductionIn recent years, computer vision has gained popularity and has become a separate direction. Developers are creating new applications that are used all over the world. In this direction, I am attracted by the concept of open source code. Even tech giants are ready to share new discoveries and innovations with everyone so that technology does not remain a privilege of the rich. One of these technologies is facial recognition. With proper and ethical use, this technology can be applied in many areas of life. In this article, I will show you how to create an effective facial recognition algorithm using open source tools. Face recognition: potential applicationsHere are a few potential applications of facial recognition technology. Face recognition in social networks. Facebook has replaced manually tagging images with automatically generated tag suggestions for each image uploaded to the platform. Facebook uses a simple facial recognition algorithm to analyze pixels in an image and compare it with the corresponding users. Face recognition in the field of security. A simple example of using facial recognition technology to protect personal data is unlocking a smartphone "by face". Such technology can also be implemented into the access system: a person looks into the camera, and it determines whether to allow him to enter or not. Face recognition for counting the number of people. Facial recognition technology can be used to count the number of people attending an event (for example, a conference or concert). Instead of manually counting the participants, we install a camera that can capture images of the participants' faces and give out the total number of visitors. This will help automate the process and save time. System setup: Hardware and software requirementsLet's look at how we can use facial recognition technology by turning to an open source tool available to us. I have used the following tools that I recommend to you: A webcam (Logitech C920) for building a real-time face recognition model on a Lenovo E470 ThinkPad laptop (Core i5 7th Gen). You can also use your laptop's built-in camera or a video camera with any suitable system for real-time video analysis instead of the ones I used. It is preferable to use a GPU for faster video processing. We used the Ubuntu 18.04 operating system with all the necessary software. Before proceeding to the construction of our facial recognition model, we will analyze these points in more detail. Step 1: Hardware SetupCheck if the camera is set up correctly. With Ubuntu, this is easy to do: see if the device is recognized by the operating system. To do this, follow these steps: Before connecting the webcam to the laptop, check all connected video devices by typing ls /dev/video* in the command line. As a result, a list of all video devices connected to the system will be displayed. Step 2: Software SetupStep 2.1: Installing PythonThe code listed in this article is written using Python (version 3.5). To install Python, I recommend using Anaconda– a popular Python distribution for data processing and analysis. Step 2.2: Installing OpenCVOpenCV is an open source library that is designed to create computer vision applications. OpenCV is installed using pip: Step 2.3: Install face_recognition APIWe will be using the face_recognition API, which is considered to be the simplest Python facial recognition API worldwide. To install, use: IntegrationAfter configuring the system, we proceed to the implementation. To begin with, we will create a program, and then explain what we have done. Step-by-step guideCreate a face_detector file.py and then copy the code below: Then run this Python file by typing: If everything works correctly, a new window will open with the real-time face recognition mode running. Let's summarize and explain what our code did: First, we specified the hardware on which the video analysis will be performed. Next, we made a real-time video capture frame by frame. Then we processed each frame and extracted the location of all the faces in the image. As a result, these frames were reproduced in the form of a video along with an indication of where the faces are located. Thanks for your attention
Comments
Read More
|