|
|
@@ -55,38 +55,42 @@ public class FaceCompareUtil {
|
|
|
|
|
|
@PostConstruct
|
|
|
private void init(){
|
|
|
- //从官网获取
|
|
|
- faceEngine = new FaceEngine(libpath);
|
|
|
- //激活引擎
|
|
|
- int errorCode = faceEngine.activeOnline(appid, sdkkey);
|
|
|
- if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
- throw new RuntimeException("引擎激活失败");
|
|
|
- }
|
|
|
- ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
|
|
- errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
|
|
- if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
- throw new RuntimeException("获取激活文件信息失败");
|
|
|
- }
|
|
|
- //引擎配置
|
|
|
- engineConfiguration = new EngineConfiguration();
|
|
|
- engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
|
|
|
- engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
|
|
|
- engineConfiguration.setDetectFaceMaxNum(10);
|
|
|
- engineConfiguration.setDetectFaceScaleVal(16);
|
|
|
- //功能配置
|
|
|
- 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()) {
|
|
|
- throw new RuntimeException("初始化引擎失败");
|
|
|
+ try {
|
|
|
+ //从官网获取
|
|
|
+ faceEngine = new FaceEngine(libpath);
|
|
|
+ //激活引擎
|
|
|
+ int errorCode = faceEngine.activeOnline(appid, sdkkey);
|
|
|
+ if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
+ throw new RuntimeException("引擎激活失败");
|
|
|
+ }
|
|
|
+ ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
|
|
+ errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
|
|
+ if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
+ throw new RuntimeException("获取激活文件信息失败");
|
|
|
+ }
|
|
|
+ //引擎配置
|
|
|
+ engineConfiguration = new EngineConfiguration();
|
|
|
+ engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
|
|
|
+ engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
|
|
|
+ engineConfiguration.setDetectFaceMaxNum(10);
|
|
|
+ engineConfiguration.setDetectFaceScaleVal(16);
|
|
|
+ //功能配置
|
|
|
+ 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()) {
|
|
|
+ throw new RuntimeException("初始化引擎失败");
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|