Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize face recognition by NodeJS

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to achieve face recognition in NodeJS. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Face update

We talked about face registration in the last post, where each face is bound to a unique userId, and of course, now that it is registered, it must be updated. Face update is an update for userId, and there are two possibilities:

UserId exists in face database. UserId does not exist face database.

The first situation is easy to understand, that is, it is updated when it exists. What about the second case? We can first take a look at the situation if the face inventory is on userId:

Let's run down and test the results:

You can see that in the presence of userId, the face will be successfully updated and the new face_token of the image and the position information of the face relative to the image will be returned. What if userId doesn't exist?

You can see that if the face does not exist, the wrong user is not exist will be reported. In fact, such a return is also possible, but the essence of face recognition is to improve the user experience and reduce the complexity of operation, so there is another way to silently register the face in the face database if the user does not exist, that is, add the parameter action_type: REPLACE.

PS: there is a hole in the document: the relace document is lowercase, but actually needs to be uppercase, and the optional parameter document does not have the parameter action_type.

We now add action_type parameters to this API:

Let's now test the effect with a non-existent userId:

It can be seen that if the face does not exist, directly silently register with the face database, which can greatly improve the user experience. Of course, optional parameters can also be added to this interface, so I won't demonstrate it in detail. I directly post the request parameters and the API return parameters:

Face deletion

Face deletion removes the user's face information from the user group. There are also two situations here:

User faces may exist in only one user group. User faces may exist in multiple user groups at the same time.

If the user's face information exists in only one user group, it will not be a problem to delete it directly. If a user's face exists in multiple user groups, we generally cannot delete all of them directly, because different user groups may be applied to different scenarios. GroupId specifies which user groups to delete face information from, and if it is deleted from multiple user groups at the same time, it is separated by commas.

Let's take a look at the test results:

You can see that if you can find faces that match userId and face_token in the corresponding user group, you can delete them successfully.

As an old rule, I directly paste the request parameters and return parameters:

User information query

You can know the usage of this API by looking at the title. You can query user information. Face registration and face update for silent registration are all optional user information user_info. Through this API, you can query the personal information bound by the user. This API can directly query the specified face information through the user group id and the user's userId:

Let's take a look at the test results:

You can see that the returned user_info is empty because I registered the face without saving the user's personal information. Next, paste the request parameters and return parameters:

Query user face list

A user can register multiple faces. This API can be used to query all the face information of a user in a specified user group through user group id and user userId:

Let's take a look at the test results:

The result returned is only one face information, because there is only one face corresponding to the userId, which returns the creation or update time. Next, paste the request parameters and return parameters:

Query user list

This API can be used to query all user information in a specified user group through the user group id:

Let's take a look at the test results:

The returned result will contain the information of all the userId in the groupId, and then paste the request parameters and return parameters:

Copy users to a new user group

If a user face already exists in a user group, the user face information can be directly copied to the new user group using this API. There is a problem with the official SDK documentation for this API. We can first look at the request parameters and return parameters:

Only user userId is a required parameter in the API document. In fact, after testing, all three parameters are required. Both the copied and copied face groups must already exist.

Let's take a look at the test results:

Delete user

This API can be used to delete users from a user group. The biggest difference between this API and the face deletion API is that the face deletion API deletes the specified face of a specified user in a user group. This API deletes a specified user of a user group.

Let's take a look at the test results:

You can see that success is returned, indicating that the user was successfully deleted from the specified user group. Next, paste the request parameters and return parameters:

Create a user group

This API is used to create a new user group. If the user group already exists, an error message will be returned.

Let's take a look at the test results:

You can see that success is returned, indicating that the new user group has been created successfully. Next, paste the request parameters and return parameters:

Delete a user group

This API is used to delete a user group. An error message will be returned if the user group does not exist.

Let's take a look at the test results:

You can see that if success is returned, the user group has been deleted successfully. Next, paste the request parameters and return parameters:

Query the list of user groups

This API is used to query the list of user groups

Let's take a look at the test results:

You can see that there are user groups 1 and 5. Next, paste the request parameters and return parameters:

On-line live detection

The main functions of this API are:

Basic face information: including face frame position, face space rotation angle, face confidence and other information. Face quality detection: judge face occlusion, illumination, ambiguity, integrity and other quality information. It can be used to determine whether the uploaded face meets the standard. In vivo detection based on images: based on a single picture, determine whether the face in the picture is a second remake for example: for example, user A took a picture containing a face with a mobile phone, and user B got picture two after retaking the picture. User An is used to identify the image, which generally occurs in financial account opening, real-name authentication and other links). This capability can be used in some face collection scenarios in H5 scenarios to increase the security and authenticity of face registration.

Let's take a look at the test results:

The most important return parameters here are:

Face_liveness: living score value thresholds: the latest threshold data is returned by the server. Comparing this parameter with the returned face_liveness can be used as a basis for living judgment. Frr_1e-4: 1/10000 error recognition rate threshold; frr_1e-3: 1/1000 error recognition rate threshold; frr_1e-2: 1% error recognition rate threshold. The lower the error rate is, the higher the accuracy is, and the higher the rejection rate is.

You can see that the returns values are 0. 97. It basically means it can't be the same person. Because I chose two different online pictures. Other parameters are not explained much, and then paste the request parameters and return parameters for self-understanding:

There are too many returned parameters. I only take screenshots of the required parameters:

Face comparison

The main functions of this API are:

Comparison of the similarity of two face images: compare the similarity of the faces in the two pictures and return the similarity score; a variety of picture types: support life photos, ID card photos, ID card chip photos, screen photos of four types of face comparison In vivo detection: based on the flaw analysis in the picture, determine whether the face in the picture is a second remake (for example, user A took a picture containing a face with a mobile phone, and user B got picture two after retaking the picture. User An is used to identify the image, which generally occurs in financial account opening, real name authentication and other links. ); quality inspection: returns blur, lighting and other quality inspection information to assist in judging whether the picture meets the recognition requirements

Let's take a look at the test results:

The most important return parameters here are:

Score: face similarity score

You can see that the score returned is 7.644287109. It basically means it can't be the same person. Because I chose two different online pictures. Other parameters are not explained much, and then paste the request parameters and return parameters for self-understanding:

This is the end of the article on "how to achieve face recognition in NodeJS". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 214

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report