|
|
@@ -52,7 +52,7 @@ public class FaceEngineFactory {
|
|
|
public String ARC_FACE_VERSION = "3.0";
|
|
|
|
|
|
//初始化一个图片模式引擎
|
|
|
- public FaceEngine initFaceEngineImage() throws IOException {
|
|
|
+ public FaceEngine initFaceEngineImage() {
|
|
|
//初始化IMAGE模式
|
|
|
return init();
|
|
|
}
|
|
|
@@ -161,7 +161,7 @@ public class FaceEngineFactory {
|
|
|
if (facePath.length() == faceLength) {
|
|
|
continue;
|
|
|
}
|
|
|
- facePath.delete();
|
|
|
+ facePath.deleteOnExit();
|
|
|
}
|
|
|
writeToLocal(CACHE_LIB_FOLDER + lib + suffix, inputStream);
|
|
|
}
|
|
|
@@ -180,19 +180,8 @@ public class FaceEngineFactory {
|
|
|
input.close();
|
|
|
}
|
|
|
|
|
|
- public String getPath() throws IOException {
|
|
|
- FileSystemResource resource = new FileSystemResource("../");
|
|
|
- String canonicalPath = resource.getFile().getCanonicalPath();
|
|
|
- if (StrUtil.isNotBlank(faceProperties.getLib_folder())) {
|
|
|
- canonicalPath = canonicalPath + File.separator + faceProperties.getLib_folder();
|
|
|
- }
|
|
|
- return CACHE_LIB_FOLDER;
|
|
|
- }
|
|
|
-
|
|
|
public void activation(FaceEngine faceEngine) {
|
|
|
-
|
|
|
- //
|
|
|
- String key = "";
|
|
|
+ String key;
|
|
|
String os = System.getProperty("os.name");
|
|
|
if (os.toLowerCase().startsWith("win")) {
|
|
|
key = faceProperties.getWinKey();
|
|
|
@@ -200,7 +189,6 @@ public class FaceEngineFactory {
|
|
|
key = faceProperties.getLinuxKey();
|
|
|
|
|
|
}
|
|
|
- logger.info("配置信息打印:" + faceProperties.getAppId() + ", " + key);
|
|
|
int errorCode = faceEngine.activeOnline(faceProperties.getAppId(), key);
|
|
|
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
logger.error("引擎激活失败:errorCode:{},", errorCode);
|
|
|
@@ -213,26 +201,18 @@ public class FaceEngineFactory {
|
|
|
*/
|
|
|
public void activeOnline() {
|
|
|
FaceEngine faceEngine = getFaceEngine();
|
|
|
- if (faceEngine == null) return;
|
|
|
activation(faceEngine);
|
|
|
getActiveInfo(faceEngine);
|
|
|
}
|
|
|
|
|
|
private FaceEngine getFaceEngine() {
|
|
|
- FaceEngine faceEngine = null;
|
|
|
+ FaceEngine faceEngine;
|
|
|
//默认放在资源文件下
|
|
|
-
|
|
|
- String canonicalPath = null;
|
|
|
try {
|
|
|
afterPropertiesSet();
|
|
|
} catch (IOException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ throw new ServiceException(e.getMessage());
|
|
|
}
|
|
|
- //FaceEngine 里加载sdk的方法已经写死了,没办法从打的jar文件中正确获取文件,
|
|
|
- // 里面用的System.load方法,没办法通过路径加载jar文件中的文件
|
|
|
- //所以这里只能把lib文件放在jar文件外部
|
|
|
-// canonicalPath = getPath();
|
|
|
- logger.info("获取lib文件路径!:{}", CACHE_LIB_FOLDER);
|
|
|
faceEngine = new FaceEngine(CACHE_LIB_FOLDER);
|
|
|
return faceEngine;
|
|
|
}
|
|
|
@@ -240,8 +220,6 @@ public class FaceEngineFactory {
|
|
|
|
|
|
/**
|
|
|
* 注入IMAGE 模式配置
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
@Bean
|
|
|
public EngineConfiguration getEngineConfiguration() {
|