📜 ⬆️ ⬇️

Login to a web application using face recognition



The first time I came across a logon system based on face recognition on a Lenovo laptop. It was funny, but oddly enough, it worked. Checked at a different level of lighting, with slightly modified facial expressions, with the approach and distance from the camera. The quality of recognition was surprising, there were no false positives. A big fly in the ointment, of course, was the ability to authenticate using a printed photo.

Our company offers two-factor authentication solutions that can already be called classic: one-time passwords via SMS, hardware keys and mobile applications that generate one-time passwords on users' smartphones. In parallel, we are considering additional methods of the “second factor”, in this particular case for purely scientific purposes - for obvious reasons.
')
So, the biometric authentication method presented below is not recommended for industrial use as a replacement for the first factor (password). The risk of using the method as a second factor is substantially less, but it still exists - decide for yourself. I’ll just tell you how and with what tools you can organize authentication for a web application using recognition and validation of a human face image. The hardware implementation is an ordinary webcam.


Br utility


I have been following the Open Biometrics project for a long time, and I believe that the br utility, included in the openbr kit, is currently the best tool that can help with our main task - comparing two images: the user's face, taken at login, is compared to the original, written During registration. As a result, a correspondence coefficient is given in the range from 0 to one. The syntax is pretty simple:

$ br -algorithm FaceRecognition -compare me.jpg you.jpg

The result is something like this:
[root @ facelogin] # br -algorithm FaceRecognition -compare image1.png image2.png
Set algorithm to FaceRecognition
Loading FaceRecognition
Comparing image1.png and image2.png
Enrolling image1.png to image1jR5xN2.mem
00.00% ELAPSED = 00: 00: 00 REMAINING = 00: 00: 00 COUNT = 1
00.00% ELAPSED = 00: 00: 00 REMAINING = 00: 00: 00 COUNT = 1
one

The last edinichka is the desired coefficient (I compared two identical files).

Face highlighting


It would not be very convenient for users to make sure that only a face and only one face fell into the camera. Therefore, our second task is to auto-detect the face in the camera image and use only this fragment for subsequent comparison using the br utility. I decided to put it on the shoulders of the browser, since HTML5’s features allow it. On the request “face detection with HTML5” Google issued neave.imtqy.com/face-detection . An excellent project that meets the requirements, and we will use it.

What happened


The neave script is slightly modified - it will transmit the coordinates and dimensions of the face through the form to the registration and entry script.
On php, registration and login scripts are quickly scribbled.

And here is the result https://face2.in/
Warning, does not work on all browsers - Chrome is recommended the latest version (desktop). For mobile browsers there will be a fallback on photo upload.

If you are interested and want to repeat on your server, here is a list of links
1. Installation instructions for the openbr package (it is easy to install on ubuntu, I had to suffer with the centos, with windows without problems at all)
2. Face Detection in JavaScript with getUserMedia
3. The source code of the demo project (yes, all standards and recommendations are violated - therefore I ask the php code not to comment - this is just to show how it works) - do not forget to allow / usr / local / bin / br to run php and set the permission to write for the $ facestorage directory

Source: https://habr.com/ru/post/229263/


All Articles