The content of the article
Why face authentication
There are several authentication options using biometrics, and each of them has its drawbacks.
- Fingerprint identification. I wrote about this method in the article “Magic“ fingers ”. How do fingerprint authentication mechanisms work? ” The main drawback of fingerprint identification is its relatively low accuracy. The fingerprint is easy to fake, especially if the scanner is weak.
- The imprint of the voice. Our voice can be broken down into many unique characteristics. You can learn more about this in the article “Machine Hearing. How does the identification of a person by his voice. ” But this method is also very inaccurate: due to illness or smoking, the unique characteristics of the voice may change, and your device will no longer recognize you.
- Retinal and iris scanners. They use sophisticated algorithms and expensive bulky scan tools. On average, the reliability of such devices is higher than that of simpler devices to implement. But the cost of such scanners is appropriate: basic models are sold at a price of fifteen thousand rubles.
- 3D face identification. This method is becoming more popular due to the favorable price-performance ratio. 3D cameras operate in different ranges, so facial recognition and identification systems can be invisible and do not require any action from a person. The accuracy of the analysis of the surface of the face is high, so it all depends on the resolution of the camera.
I chose an inexpensive, but functional camera Intel RealSense SR305, which can shoot both a color image and an in-depth image in a resolution of 640 by 480 pixels with a frequency of up to 60 frames per second.
To obtain a three-dimensional image, the camera uses a small infrared emitter that projects uniform lines onto objects in front of it. From the curvature of these lines, the camera understands how far or close these objects are.
The working distance of the camera is small: the emitter is located so that objects that are closer than twenty centimeters will not be illuminated and, accordingly, will not be scanned. Objects that are too far away – beyond two meters – will also not be visible, because the laser power will not allow them to project an infrared grid.
Included with the camera is a USB wire and instructions with a link to the official SDK in repositories on github.
First of all, you need to install the software for the camera to work. Windows users can simply download and install the program. If you have Linux, but not Ubuntu 16 or 18, you will have to build the project yourself.
To get started, download the source code and prepare the site for assembly.
$ git clone https://github.com/IntelRealSense/librealsense.git$ cd librealsense$ mkdir build && cd build
Now you can build a project to see how the camera works.
$ cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false$ make -j4$ make install
Launch on macOS
If you are a macOS user, you will have to use Xcode and the corresponding flag during configuration to run graphics programs. So you can generate an Xcode project to run each utility individually.
$ cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -G Xcode$ open librealsense2.xcodeproj
The Xcode window opens. Choose the necessary program, assemble the project by pressing Command + B and press the Build and run button.
For a trial run, we need the RealSense Viewer utility, which shows on the screen what the camera sees.
We will try to write our own program for identification using a three-dimensional image of a face. And for starters, we need to connect the RealSense library, for example, to Python 3. Windows users and some Linux distributions do not have to strain – you can take the official package
pyrealsense2 in PyPI.
$ pip install pyrealsense2
The rest is waiting for another adventure: it is necessary to rebuild the entire project, adding wrapper for Python to the flags.
$ cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_PYTHON_BINDINGS:bool=true$ make -j4
wrappers/python/ two files and four symbolic links will appear. To use these files as a library for Python, you need to copy them to the folder from which you will run the scripts.
Continuation is available only to participants
Materials from the latest issues become available separately only two months after publication. To continue reading, you must become a member of the Xakep.ru community.
Join the Xakep.ru Community!
Membership in the community during the specified period will open you access to ALL Hacker materials, increase your personal cumulative discount and allow you to accumulate a professional Xakep Score!