2023-03-20 18:46:31 +08:00
|
|
|
package com.zhgd.xmgl.config;
|
|
|
|
|
|
|
|
|
|
import com.arcsoft.face.ActiveFileInfo;
|
|
|
|
|
import com.arcsoft.face.EngineConfiguration;
|
|
|
|
|
import com.arcsoft.face.FaceEngine;
|
|
|
|
|
import com.arcsoft.face.FunctionConfiguration;
|
|
|
|
|
import com.arcsoft.face.enums.DetectMode;
|
|
|
|
|
import com.arcsoft.face.enums.DetectOrient;
|
|
|
|
|
import com.arcsoft.face.enums.ErrorInfo;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.boot.CommandLineRunner;
|
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @program: wisdomSite
|
|
|
|
|
* @description: 虹软人脸识别插件初始化
|
|
|
|
|
* @author: Mr.Peng
|
|
|
|
|
* @create: 2021-04-08 10:18
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
|
@Order(value = 2)
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class FaceRunner implements CommandLineRunner {
|
|
|
|
|
|
|
|
|
|
public static FaceEngine faceEngine;
|
|
|
|
|
@Value("${arcsoft.appId}")
|
|
|
|
|
private String appId;
|
|
|
|
|
@Value("${arcsoft.sdkKey}")
|
|
|
|
|
private String winsSdkKey;
|
|
|
|
|
@Value("${arcsoft.linux.sdkKey}")
|
|
|
|
|
private String linuxSdkKey;
|
|
|
|
|
@Value("${arcsoft.dllPath}")
|
|
|
|
|
private String dllPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run(String... args) throws Exception {
|
|
|
|
|
String os = System.getProperty("os.name");
|
|
|
|
|
log.info("服务器系统" + os);
|
|
|
|
|
//如果是Windows系统
|
2023-03-24 17:33:44 +08:00
|
|
|
if (os.toLowerCase().startsWith("win") || os.toLowerCase().startsWith("linux")) {
|
|
|
|
|
String sdkKey = "";
|
|
|
|
|
if (os.toLowerCase().startsWith("linux")) {
|
|
|
|
|
sdkKey = linuxSdkKey;
|
|
|
|
|
} else {
|
|
|
|
|
sdkKey = winsSdkKey;
|
|
|
|
|
}
|
|
|
|
|
//log.info(HCNetSDKPath.DLL_PATH+"dll");
|
|
|
|
|
log.info(dllPath);
|
|
|
|
|
faceEngine = new FaceEngine(dllPath);
|
|
|
|
|
//激活引擎
|
|
|
|
|
int errorCode = faceEngine.activeOnline(appId, sdkKey);
|
2023-03-20 18:46:31 +08:00
|
|
|
|
2023-03-24 17:33:44 +08:00
|
|
|
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
2023-03-20 18:46:31 +08:00
|
|
|
log.info("引擎激活失败,errorCode:" + errorCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
|
|
|
|
errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
|
|
|
|
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
|
|
log.info("获取激活文件信息失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//引擎配置
|
|
|
|
|
EngineConfiguration engineConfiguration = new EngineConfiguration();
|
|
|
|
|
engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
|
|
|
|
|
engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
|
|
|
|
|
engineConfiguration.setDetectFaceMaxNum(10);
|
|
|
|
|
engineConfiguration.setDetectFaceScaleVal(16);
|
|
|
|
|
//功能配置
|
|
|
|
|
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);
|
|
|
|
|
engineConfiguration.setFunctionConfiguration(functionConfiguration);
|
|
|
|
|
//初始化引擎
|
|
|
|
|
errorCode = faceEngine.init(engineConfiguration);
|
|
|
|
|
|
|
|
|
|
if (errorCode != ErrorInfo.MOK.getValue()) {
|
|
|
|
|
log.info("初始化引擎失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|