最近遇到个问题,用SpringBoot开发的程序,里面调用于虹软的人脸识别DLL,在IDEA上面运行正常,但打成JAR包后运行程序出错,无法对DLL初始化.经调试确认为DLL路径识别不了问题,解决方法把相关DLL放 windows/system32目录或自行指定path路径即可解决.
方法一:
直接把DLL放于 windows/system32 目录下
方法二:指定PATH路径
在创建 FaceEngine时指定路径
public FaceEngine createFaceEngine(){
String libPath= getPath() + "/arcfacelib"; //jar包当前目录下的 arcfacelib 目录
FaceEngine faceEngine = new FaceEngine(libPath);
//激活引擎
String appId = ArcFaceID.appId;
String sdkKey = ArcFaceID.sdkKey;
int activeCode = faceEngine.activeOnline(appId, sdkKey);
if (activeCode != ErrorInfo.MOK.getValue() && activeCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
logger.info("引擎激活失败:"+activeCode);
}else {
logger.info("引擎激活成功:"+activeCode);
}
ActiveFileInfo activeFileInfo=new ActiveFileInfo();
activeCode = faceEngine.getActiveFileInfo(activeFileInfo);
if (activeCode != ErrorInfo.MOK.getValue() && activeCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
logger.info("获取激活文件信息失败");
}
//引擎配置
EngineConfiguration engineConfiguration = new EngineConfiguration();
engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_0_ONLY);
engineConfiguration.setDetectFaceMaxNum(10);
engineConfiguration.setDetectFaceScaleVal(16);
//功能配置
FunctionConfiguration functionConfiguration = new FunctionConfiguration();
functionConfiguration.setSupportAge(false);
functionConfiguration.setSupportFace3dAngle(false);
functionConfiguration.setSupportFaceDetect(true);
functionConfiguration.setSupportFaceRecognition(true);
functionConfiguration.setSupportGender(false);
functionConfiguration.setSupportLiveness(true);
functionConfiguration.setSupportIRLiveness(false);
engineConfiguration.setFunctionConfiguration(functionConfiguration);
//初始化引擎
int initCode = faceEngine.init(engineConfiguration);
if (initCode != ErrorInfo.MOK.getValue()) {
logger.info("初始化引擎失败:"+initCode);
}else {
logger.info("引擎初始化成功:"+activeCode);
}
return faceEngine;