应用场景:
将标记的人脸信息,通过虹软sdk实现人脸识别,将识别到的结果发送到android客户端,通知业务人员,从而第一时间获取客户信息,可以用迎宾系统,商超特殊人员通知系统等.
效果图如下:
视频效果如下:
人脸识别迎宾系统
功能点
- 人脸识别
- 人脸底库批量入库
- 视频或摄像头人脸识别功能
- Android端实时接收人脸信息
- Android语音播报人脸信息
开发工具
- IDEA
- Android Studio
- Navicat for mysql
- Maven
技术架构
- windows 10
- java 8 win_x64
- spring boot
- mysql 5.7+
- android
- 虹软人脸识别sdk增值版 java 4.0
运行须知
-
1.下载源码,源码地址:https://gitee.com/x55admin/ArcSoftFaceDemo
其中ArcSoftFaceServer -服务器端源码 AndroidFaceClient -Android客户端源码
idea打开服务器端源码并通过maven 下载所需要的库文件,
Android Studio打开客户端源码 -
2.在mysql中创建arc_face_base 数据库,数据库编码为utf8mb4, 将服务器端源码ArcSoftFaceServer的doc目录中user_face_info.sql的内容导入到数据库arc_face_base中,生成user_face_info表
-
2.到虹软官网http://ai.arcsoft.com.cn/ 免费申请下载虹软人脸识别增值版 java 4.0 SDK,增值版支持试用,
按引导操作,申请并下载ArcSoft_ArcFacePro_windows_x64_java_V4.0 其中libs/WIN64文件夹下包含
libarcsoft_face.dll
libarcsoft_face_engine.dll
libarcsoft_face_engine_jni.dll
注意区分X86和X64,和当前jdk版本一致。 -
3.将服务器端源码,更改为自己的配置信息,首先更改修改配置文件src\main\resources\application.properties
配置如下内容
config.arcface-sdk.sdk-lib-path -人脸识别引擎库存放路径(即为ArcSoft_ArcFacePro_windows_x64_java_V4.0\libs\WIN64的绝对路径)
config.arcface-sdk.base-image-path -人脸底库图片存放绝对路径
config.arcface-sdk.jar-path -人脸库jar包存放路径(ArcSoftFaceServer\lib的绝对路径)
config.arcface-sdk.app-id -虹软申请试用SDK的APP_ID
config.arcface-sdk.sdk-key -虹软申请试用SDK的SDK_KEY
config.arcface-sdk.active-key -虹软申请试用SDK的Active_Key
spring.datasource.druid.url -数据库连接
spring.datasource.druid.username -数据库用户名
spring.datasource.druid.password -数据库密码
可以用com.itboyst.facedemo.FaceEngineTest测试SDK是否能正常运行
package com.itboyst.facedemo;
import com.arcsoft.face.*;
import com.arcsoft.face.enums.DetectMode;
import com.arcsoft.face.enums.DetectModel;
import com.arcsoft.face.enums.DetectOrient;
import com.arcsoft.face.enums.ExtractType;
import com.arcsoft.face.toolkit.ImageFactory;
import com.arcsoft.face.toolkit.ImageInfo;
import com.arcsoft.face.toolkit.ImageInfoEx;
import com.itboyst.facedemo.util.ShowVideo;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import static com.itboyst.facedemo.util.ShowVideo.getProperties;
public class FaceEngineTest {
public static void main(String[] args) {
//激活码,从官网获取
String appId = getProperties("application.properties", "config.arcface-sdk.app-id");
String sdkKey = getProperties("application.properties", "config.arcface-sdk.sdk-key");
String activeKey = getProperties("application.properties", "config.arcface-sdk.active-key");
System.err.println("注意,如果返回的errorCode不为0,可查看com.arcsoft.face.enums.ErrorInfo类获取相应的错误信息");
//获取properties中配置信息
String sdkLibPath = getProperties("application.properties", "config.arcface-sdk.sdk-lib-path");
System.out.println("------------------" + sdkLibPath);
//人脸识别引擎库存放路径
FaceEngine faceEngine = new FaceEngine(sdkLibPath);
//激活引擎
int errorCode = faceEngine.activeOnline(appId, sdkKey, activeKey);
System.out.println("引擎激活errorCode:" + errorCode);
ActiveDeviceInfo activeDeviceInfo = new ActiveDeviceInfo();
//采集设备信息(可离线)
errorCode = faceEngine.getActiveDeviceInfo(activeDeviceInfo);
System.out.println("采集设备信息errorCode:" + errorCode);
System.out.println("设备信息:"+activeDeviceInfo.getDeviceInfo());
//faceEngine.activeOffline("d:\\ArcFacePro64.dat.offline");
//ActiveFileInfo activeFileInfo = new ActiveFileInfo();
//errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
//System.out.println("获取激活文件errorCode:" + errorCode);
//System.out.println("激活文件信息:" + activeFileInfo.toString());
//引擎配置
EngineConfiguration engineConfiguration = new EngineConfiguration();
engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
engineConfiguration.setDetectFaceMaxNum(10);
//功能配置
FunctionConfiguration functionConfiguration = new FunctionConfiguration();
functionConfiguration.setSupportAge(true);
functionConfiguration.setSupportFace3dAngle(true);
functionConfiguration.setSupportFaceDetect(true);
functionConfiguration.setSupportFaceRecognition(true);
functionConfiguration.setSupportGender(true);
functionConfiguration.setSupportLiveness(true);
functionConfiguration.setSupportIRLiveness(true);
functionConfiguration.setSupportImageQuality(true);
functionConfiguration.setSupportMaskDetect(true);
functionConfiguration.setSupportFaceLandmark(true);
functionConfiguration.setSupportUpdateFaceData(true);
functionCo