Android development face recognition login function

Recently, many company apps have realized the function of face recognition login. Today, yinpeng took you to do this face recognition login from beginning to end.

First of all, we need to adopt a platform with face recognition algorithm. Here, I suggest using hongruan face recognition, because this is what I personally use. The key advantage is that it is free. Registration link: Click to enter registration.

After registration, without much to say, we enter the process.

Step 1: create an application on hongsoft platform

Directly install SDK to view activation code

Download hongsoft identification library address: click download identification library

Add dependency after downloading:

implementation 'com.github.tyhjh:PermissionUtil:v1.0.5'
implementation 'com.github.tyhjh:picturePickUtil:v1.0.6'
implementation project(':arclibrary')

Next, go to the detailed steps:

Step 1: initialize in the application:

private void initArcFace() {
  new AcrFaceManagerBuilder().setContext(this)
    .setFreeSdkAppId(Constants.FREESDKAPPID)
    .setFdSdkKey(Constants.FDSDKKEY)
    .setFtSdkKey(Constants.FTSDKKEY)
    .setFrSdkKey(Constants.FRSDKKEY)
    .setLivenessAppId(Constants.LIVENESSAPPID)
    .setLivenessSdkKey(Constants.LIVENESSSDKKEY)
    .create();
 }

Warm tip: constants is a constant class that stores soft information. It mainly stores appid and other information. These information is contained in the view activation code.

public class Constants {
 public static String FREESDKAPPID = "ELVF52xrBj21FKQxXygS6HvkdoMzeUVaAcBDtLa1vu4F";
 public static String FDSDKKEY = "59nZG5b13BNroFAyvMW74PEMD5Ke5ieWiZK1n6YVTEoe";
 public static String FTSDKKEY = "59nZG5b13BNroFAyvMW74PEE3g4RPbX4UPAn1XV7Hcra";
 public static String FRSDKKEY = "59nZG5b13BNroFAyvMW74PEqrgNHG1iZPTi78m1mctQt";
 public static String IDCARDAPPID = "ELVF52xrBj21FKQxXygS6HvkdoMzeUVaAcBDtLa1vu4F";
 public static String IDCARDSDKKEY = "";
 public static String LIVENESSAPPID = "ELVF52xrBj21FKQxXygS6HvkdoMzeUVaAcBDtLa1vu4F";
 public static String LIVENESSSDKKEY = "59nZG5b13BNroFAyvMW74PEMD5Ke5ieWiZK1n6YVTEoe";
}

Some need to download the code in the arc file. This is the download address: Click to download the arc code [the main business logic is put in livenessactivity]

Face recognition registration

 LivenessActivity.flag = 1;
 startActivity(new Intent(MainActivity.this,LivenessActivity.class));

Face recognition login

LivenessActivity.flag = 2;
startActivity(new Intent(MainActivity.this,LivenessActivity.class));

The above is only local registration and login. We need to interact with the server. When registering, we need to bind the faceid and store the faceid. When the user turns on face recognition, we will verify the local face recognition login. After success, we will request the face brushing login interface.

For face recognition, some friend so libraries cannot be found. It should conflict with the architecture of the third party it depends on. The solution is as follows. Specify the architecture method under app, Android and defaultconfig:

ndk {
   //选择要添加的对应cpu类型的.so库。 // 还可以添加 'x86','x86_64','mips','mips64'
   abiFilters 'armeabi-v7a' //'armeabi-v7a','arm64-v8a'
   moduleName "app"
  }
  sourceSets {
   main {
    jniLibs.srcDirs = ['src/main
bs']//指定你的libs路径
   }
  }

Face recognition demo download experience:

Link:

https://pan.baidu.com/s/1EP6qnF-KN1gZo0r0RAGhQA

Extraction code: fya2

summary

The above is the Android development face recognition login function introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support to our website! If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>