Login to web application using face recognition

    The first time I came across a login system based on face recognition on a laptop from Lenovo . It was funny, but oddly enough, it worked. Checked at different levels of lighting, with slightly modified facial expressions, with approaching and moving away from the camera. The recognition quality was surprising, there were no false positives. A big fly in the ointment, of course, was the possibility of authentication using a printed photograph.

    Our company offers solutions for two-factor authentication, which 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 significantly less, but 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 the image of a human face. The hardware implementation is a regular webcam.

    Utility br

    I have been following the Open Biometrics project for a long time , and I believe that the br utility included with openbr is currently the best tool that can help with our main task - comparing two images: the user's face photographed by login is compared with the original recorded when registering. As a result, a compliance coefficient in the range from 0 to unity is issued. 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

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

    Face selection

    It would not be very convenient for users to ensure that only the face gets into the camera, and only one. Therefore, our second task is to auto-detect the face in the camera picture and use only this fragment for subsequent comparison using the br utility. I decided to shift this onto the shoulders of the browser, since HTML5 allows it. At the request of “face detection with HTML5,” Google issued neave.github.io/face-detection . An excellent project, meets the requirements, and we will use it.

    What happened

    The script from neave is slightly modified - it will transfer the coordinates and sizes of the face through the form to the registration and login script.
    On php scripts of registration and login are quickly sketched.

    And here is the result of https://face2.in/
    Attention, it doesn’t work on all browsers - Chrome of the latest version (desktop) is recommended. For mobile browsers, there will be a fallback to download photos.

    If you are interested and want to repeat it on your server, here is the list of links
    1. Instructions for installing the openbr package (it is easy to install on ubuntu, I had to suffer with centos, windows without any problems)
    2. Face Detection in JavaScript with getUserMedia
    3 . Sources demo of the project (yes, all standards and recommendations have been violated - so 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 be executed in php and set write permission for the $ directory facestorage

    Also popular now: