Skip to content

Face Detection api will let your application to login or register with face detection faster and better than usual

Notifications You must be signed in to change notification settings

Alireza17224/Face-Detection

Repository files navigation

Face-Detection Api

ezgif-3-d8547e8dd2

Hi ! I am Alireza Mosavi a developer .

I would like to introduce my Face-Detection-Api can make login or sign-up faster and easier.

Face-Detection Api packages

In this api I used Node.js for deploying.

Also i have used these libraries.

@tensorflow/tfjs-node": 3.12.0

@vladmandic/face-api": 1.6.1

body-parser:1.19.1

canvas: 2.8.0

express: 4.17.1

express-fileupload: 1.2.1

mkdirp: 1.0.4

node-json-db: 1.4.1

path: 0.12.7

uuid: 8.3.2

Face-Detection Api Testing

For testing application first you need to clone it :

git init
git clone https://github.com/Alireza17224/Face-Detection

After That these files will be downloaded for you.

Picture1

after that find the folder that you cloned the files in it and then open admin powershell.

Picture2

You need to download npm before using this api

Then Please type

npm install

Downloading

Then for running the js file type

node app.js

Now the api is available in http://localhost:3000

Picture4

You can send requests by Postman Application.

postman

Using this api in your projects

For using this api in your project you can do what you like or prefer.

But See this pictures first.

Picture1

Picture2

Picture3

line 210 app.js
line 215 app.js
line 499 app.js

For using routers , you need to change the path file on top lines.

Models Folder also is really necessary and you need to have it for your api.

How it Works

For authentication this api support two parts. if you want forget-password || reset-password you can do it easily with this api.Scroll than for more detail

  • 1 . Register

  • 2 . Login

Request register part

For Register part please open your postman application first and send a POST request . The Address of api for register is below down .

http://localhost:3000/register

In the body of request you need to add photo of user image that you got it from user register form .

Like Image below.

postman

Response register part

{
    "age": number,
    "expression": feeling,
    "gender": gender,
    "token": randomToken,
}
  • 1 . age key will be a number , age of the user .

  • 2 . expression key will be a feeling that user had in image .

  • 3 . gender key will be female || male .

  • 4 . token key ! Most important key is token . as you know in database you know to have a id , token is id that it will be store in database and you can find user with that token

This data + Image Description (coordinate position of face points) will be stored in Database.json .

For storing data we are using node-json-db

Request login part

For login part please open your postman application first and send a POST request . The Address of api for login is below down .

http://localhost:3000/login

In the body of request you need to add photo of user image that you got it from user login form .

Like Image below.

loginRequest

Response login part

{
    "faceMatch": bool,
    "token": a random token,
    "status": bool,
    "isTrusted": bool,
    "distance": Euclidean distance between the image stored in database and new image

}
  • 1 . faceMatch key will be a bool that it will show that the face match was true || false .

  • 2 . token key will be a token or a kind of id that it will be stored in database .

  • 3 . status key will be a bool that it will show that the operation performed successfully or no .

  • 4 . is trusted key will be a bool that will be show that you can trust the response or no .

  • 5 . distance key will be Euclidean distance between the image stored in database and new image

with token in response you can get user data such as (age,feeling,gender) from database.json

getdata

Also you can see the response of login in your command line

What is threshold ?

with Euclidean distance between the image stored in the database and the image in form we can underestand the distance.

const threshold = 0.50;
line 168 app.js

you can change the threshold but it's not preferred. threshold less than 0.50 can make the api very sensetive but above 0.50 can make the security really weak.

Frontend

if you don't know how to perform the frontend system and take photo from user image please look at link below.

Frontend

This template is using webcam-easy.js

Contributions

Face-Detection-Api is an open-source package , so contributions are warmly welcome whether that be a code , docs or typo just fork it.

when contributing to code please make an issue for that before making your changes so that we can have a discussion before implementation.

Give it a star

If this program was useful to you, please give this program a star so that others will trust our api faster .

Problem

if you face any error please send the error in issues of github or in my email address [email protected]

I will solved it fast

Thank you for reading

About

Face Detection api will let your application to login or register with face detection faster and better than usual

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published