This commit is contained in:
parent
87f66ad049
commit
56c277293e
|
|
@ -5,6 +5,7 @@ import com.arcsoft.face.enums.DetectMode;
|
||||||
import com.arcsoft.face.enums.DetectOrient;
|
import com.arcsoft.face.enums.DetectOrient;
|
||||||
import com.arcsoft.face.enums.ErrorInfo;
|
import com.arcsoft.face.enums.ErrorInfo;
|
||||||
import com.arcsoft.face.enums.ImageFormat;
|
import com.arcsoft.face.enums.ImageFormat;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -26,6 +27,7 @@ import java.util.List;
|
||||||
* @author zys
|
* @author zys
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class ArcFaceHelper {
|
public class ArcFaceHelper {
|
||||||
|
|
||||||
@Value("${face.arc-face.app-id}")
|
@Value("${face.arc-face.app-id}")
|
||||||
|
|
@ -66,18 +68,18 @@ public class ArcFaceHelper {
|
||||||
// faceEngine = new FaceEngine("D:\\arcsoft_lib_64");
|
// faceEngine = new FaceEngine("D:\\arcsoft_lib_64");
|
||||||
// //激活引擎
|
// //激活引擎
|
||||||
// int code = faceEngine.activeOnline(APP_ID, WIN64_SDK_KEY);
|
// int code = faceEngine.activeOnline(APP_ID, WIN64_SDK_KEY);
|
||||||
// System.out.println("引擎激活code:" + code);
|
// log.info("引擎激活code:" + code);
|
||||||
// } else {
|
// } else {
|
||||||
// faceEngine = new FaceEngine(faceEnginePath);
|
// faceEngine = new FaceEngine(faceEnginePath);
|
||||||
// //激活引擎
|
// //激活引擎
|
||||||
// errorCode = faceEngine.activeOnline(APP_ID, LINUX64_SDK_KEY);
|
// errorCode = faceEngine.activeOnline(APP_ID, LINUX64_SDK_KEY);
|
||||||
// }
|
// }
|
||||||
// System.out.println("引擎激活code:" + errorCode);
|
// log.info("引擎激活code:" + errorCode);
|
||||||
// }catch (Throwable e){
|
// }catch (Throwable e){
|
||||||
// System.out.println("加载人脸识别引擎异常:" + e.getMessage());
|
// log.info("加载人脸识别引擎异常:" + e.getMessage());
|
||||||
// }
|
// }
|
||||||
// if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
// if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||||
// System.out.println("引擎激活失败");
|
// log.info("引擎激活失败");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
@ -86,9 +88,9 @@ public class ArcFaceHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FaceResult getFaceFeatures(String imgSrc) {
|
public FaceResult getFaceFeatures(String imgSrc) {
|
||||||
System.out.println("-----getFaceFeatures");
|
log.info("-----getFaceFeatures");
|
||||||
if(imgSrc.contains("http")){
|
if(imgSrc.contains("http")){
|
||||||
System.out.println("-----imgSrc.contains(http)");
|
log.info("-----imgSrc.contains(http)");
|
||||||
return getFaceFeatures(getNetUrlHttp(imgSrc));
|
return getFaceFeatures(getNetUrlHttp(imgSrc));
|
||||||
}else{
|
}else{
|
||||||
return getFaceFeatures(new File(imgSrc));
|
return getFaceFeatures(new File(imgSrc));
|
||||||
|
|
@ -102,7 +104,7 @@ public class ArcFaceHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static FaceResult getFaceFeatures(File file) {
|
public static FaceResult getFaceFeatures(File file) {
|
||||||
System.out.println("-----开始识别");
|
log.info("-----开始识别");
|
||||||
|
|
||||||
int errorCode = 0;
|
int errorCode = 0;
|
||||||
try{
|
try{
|
||||||
|
|
@ -116,12 +118,12 @@ public class ArcFaceHelper {
|
||||||
//激活引擎
|
//激活引擎
|
||||||
errorCode = faceEngine.activeOnline(appId, linuxKey);
|
errorCode = faceEngine.activeOnline(appId, linuxKey);
|
||||||
}
|
}
|
||||||
System.out.println("引擎激活code:" + errorCode);
|
log.info("引擎激活code:" + errorCode);
|
||||||
}catch (Throwable e){
|
}catch (Throwable e){
|
||||||
System.out.println("加载人脸识别引擎异常:" + e.getMessage());
|
log.info("加载人脸识别引擎异常:" + e.getMessage());
|
||||||
}
|
}
|
||||||
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||||
System.out.println("引擎激活失败");
|
log.info("引擎激活失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -142,7 +144,7 @@ public class ArcFaceHelper {
|
||||||
//初始化引擎
|
//初始化引擎
|
||||||
int faceEngineInitCode = faceEngine.init(engineConfiguration);
|
int faceEngineInitCode = faceEngine.init(engineConfiguration);
|
||||||
if (faceEngineInitCode != ErrorInfo.MOK.getValue()){
|
if (faceEngineInitCode != ErrorInfo.MOK.getValue()){
|
||||||
System.out.println("初始化引擎失败" + faceEngineInitCode);
|
log.info("初始化引擎失败" + faceEngineInitCode);
|
||||||
}
|
}
|
||||||
//人脸检测
|
//人脸检测
|
||||||
List<FaceInfo> lstFaceInfo = new ArrayList<FaceInfo>();
|
List<FaceInfo> lstFaceInfo = new ArrayList<FaceInfo>();
|
||||||
|
|
@ -186,7 +188,7 @@ public class ArcFaceHelper {
|
||||||
|
|
||||||
public static void unInintEngine() {
|
public static void unInintEngine() {
|
||||||
int code = faceEngine.unInit();
|
int code = faceEngine.unInit();
|
||||||
System.out.println("销毁引擎:" + code);
|
log.info("销毁引擎:" + code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageInfo getRGBData(File file) {
|
public static ImageInfo getRGBData(File file) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue