去除人脸识别
This commit is contained in:
parent
2c6a8b69f3
commit
538e4c3369
@ -1,92 +1,92 @@
|
||||
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系统
|
||||
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);
|
||||
|
||||
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||
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("初始化引擎失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//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系统
|
||||
// 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);
|
||||
//
|
||||
// if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||
// 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("初始化引擎失败");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
@ -1,42 +1,41 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.arcsoft_face;
|
||||
|
||||
import com.arcsoft.face.FaceFeature;
|
||||
import com.arcsoft.face.FaceInfo;
|
||||
import com.arcsoft.face.toolkit.ImageInfo;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.arcsoft_face.handler.FacesHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
||||
|
||||
@Component
|
||||
public class FaceApi {
|
||||
|
||||
@Autowired
|
||||
private FacesHandler facesHandler;
|
||||
/**
|
||||
* 人像比对(图片和图片)
|
||||
* @param idCardFront 身份证图片
|
||||
* @param feature 人像图片
|
||||
*/
|
||||
public float compareFaceFeature(String idCardFront, String feature) {
|
||||
try {
|
||||
ImageInfo imageInfo = getRGBData(new File(idCardFront));
|
||||
ImageInfo imageInfo1 = getRGBData(new File(feature));
|
||||
// 人脸检测
|
||||
List<FaceInfo> faceInfos = facesHandler.detectFaces(imageInfo);
|
||||
List<FaceInfo> faceInfos1 = facesHandler.detectFaces(imageInfo1);
|
||||
// 特征提取
|
||||
FaceFeature faceFeature = facesHandler.extractFaceFeature(imageInfo, faceInfos);
|
||||
FaceFeature faceFeature1 = facesHandler.extractFaceFeature(imageInfo1, faceInfos1);
|
||||
// 特征对比
|
||||
return facesHandler.compareFaceFeature(faceFeature, faceFeature1);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("比对失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package com.zhgd.xmgl.modules.basicdata.api.arcsoft_face;
|
||||
//
|
||||
//import com.arcsoft.face.FaceFeature;
|
||||
//import com.arcsoft.face.FaceInfo;
|
||||
//import com.arcsoft.face.toolkit.ImageInfo;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
||||
//
|
||||
//@Component
|
||||
//public class FaceApi {
|
||||
//
|
||||
// @Autowired
|
||||
// private FacesHandler facesHandler;
|
||||
// /**
|
||||
// * 人像比对(图片和图片)
|
||||
// * @param idCardFront 身份证图片
|
||||
// * @param feature 人像图片
|
||||
// */
|
||||
// public float compareFaceFeature(String idCardFront, String feature) {
|
||||
// try {
|
||||
// ImageInfo imageInfo = getRGBData(new File(idCardFront));
|
||||
// ImageInfo imageInfo1 = getRGBData(new File(feature));
|
||||
// // 人脸检测
|
||||
// List<FaceInfo> faceInfos = facesHandler.detectFaces(imageInfo);
|
||||
// List<FaceInfo> faceInfos1 = facesHandler.detectFaces(imageInfo1);
|
||||
// // 特征提取
|
||||
// FaceFeature faceFeature = facesHandler.extractFaceFeature(imageInfo, faceInfos);
|
||||
// FaceFeature faceFeature1 = facesHandler.extractFaceFeature(imageInfo1, faceInfos1);
|
||||
// // 特征对比
|
||||
// return facesHandler.compareFaceFeature(faceFeature, faceFeature1);
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException("比对失败");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@ -1,64 +1,64 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.arcsoft_face.handler;
|
||||
|
||||
import com.arcsoft.face.FaceFeature;
|
||||
import com.arcsoft.face.FaceInfo;
|
||||
import com.arcsoft.face.FaceSimilar;
|
||||
import com.arcsoft.face.toolkit.ImageInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
||||
|
||||
|
||||
@Component
|
||||
public class FacesHandler {
|
||||
|
||||
/**
|
||||
* 人脸检测
|
||||
* @param imageInfo
|
||||
* @return
|
||||
*/
|
||||
public List<FaceInfo> detectFaces(ImageInfo imageInfo) {
|
||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||
int resultCode = faceEngine.detectFaces(imageInfo.getImageData(),
|
||||
imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(),
|
||||
faceInfoList);
|
||||
return (faceInfoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 人脸特征提取
|
||||
* @param imageInfo
|
||||
* @param faceInfoList
|
||||
* @return
|
||||
*/
|
||||
public FaceFeature extractFaceFeature(ImageInfo imageInfo, List<FaceInfo> faceInfoList) {
|
||||
FaceFeature faceFeature = new FaceFeature();
|
||||
int resultCode = faceEngine.extractFaceFeature(imageInfo.getImageData(),
|
||||
imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(),
|
||||
faceInfoList.get(0), faceFeature);
|
||||
return faceFeature;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 人脸比对
|
||||
* @param faceFeature
|
||||
* @param faceFeature1
|
||||
* @return
|
||||
*/
|
||||
public float compareFaceFeature(FaceFeature faceFeature, FaceFeature faceFeature1) {
|
||||
FaceFeature targetFaceFeature = new FaceFeature();
|
||||
targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
|
||||
FaceFeature sourceFaceFeature = new FaceFeature();
|
||||
sourceFaceFeature.setFeatureData(faceFeature1.getFeatureData());
|
||||
FaceSimilar faceSimilar = new FaceSimilar();
|
||||
int resultCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature,
|
||||
faceSimilar);
|
||||
System.out.println("比对结果:相似度:" + faceSimilar.getScore());
|
||||
return faceSimilar.getScore();
|
||||
}
|
||||
|
||||
}
|
||||
//package com.zhgd.xmgl.modules.basicdata.api.arcsoft_face.handler;
|
||||
//
|
||||
//import com.arcsoft.face.FaceFeature;
|
||||
//import com.arcsoft.face.FaceInfo;
|
||||
//import com.arcsoft.face.FaceSimilar;
|
||||
//import com.arcsoft.face.toolkit.ImageInfo;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
||||
//
|
||||
//
|
||||
//@Component
|
||||
//public class FacesHandler {
|
||||
//
|
||||
// /**
|
||||
// * 人脸检测
|
||||
// * @param imageInfo
|
||||
// * @return
|
||||
// */
|
||||
// public List<FaceInfo> detectFaces(ImageInfo imageInfo) {
|
||||
// List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||
// int resultCode = faceEngine.detectFaces(imageInfo.getImageData(),
|
||||
// imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(),
|
||||
// faceInfoList);
|
||||
// return (faceInfoList);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 人脸特征提取
|
||||
// * @param imageInfo
|
||||
// * @param faceInfoList
|
||||
// * @return
|
||||
// */
|
||||
// public FaceFeature extractFaceFeature(ImageInfo imageInfo, List<FaceInfo> faceInfoList) {
|
||||
// FaceFeature faceFeature = new FaceFeature();
|
||||
// int resultCode = faceEngine.extractFaceFeature(imageInfo.getImageData(),
|
||||
// imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(),
|
||||
// faceInfoList.get(0), faceFeature);
|
||||
// return faceFeature;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 人脸比对
|
||||
// * @param faceFeature
|
||||
// * @param faceFeature1
|
||||
// * @return
|
||||
// */
|
||||
// public float compareFaceFeature(FaceFeature faceFeature, FaceFeature faceFeature1) {
|
||||
// FaceFeature targetFaceFeature = new FaceFeature();
|
||||
// targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
|
||||
// FaceFeature sourceFaceFeature = new FaceFeature();
|
||||
// sourceFaceFeature.setFeatureData(faceFeature1.getFeatureData());
|
||||
// FaceSimilar faceSimilar = new FaceSimilar();
|
||||
// int resultCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature,
|
||||
// faceSimilar);
|
||||
// System.out.println("比对结果:相似度:" + faceSimilar.getScore());
|
||||
// return faceSimilar.getScore();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.arcsoft_face.FaceApi;
|
||||
import com.zhgd.xmgl.modules.wisdom.dto.WorkerInfoDto;
|
||||
import com.zhgd.xmgl.modules.wisdom.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.wisdom.service.IWorkerInfoService;
|
||||
@ -46,8 +45,8 @@ public class WorkerInfoController {
|
||||
@Autowired
|
||||
private IWorkerInfoService workerInfoService;
|
||||
|
||||
@Autowired
|
||||
private FaceApi faceApi;
|
||||
// @Autowired
|
||||
// private FaceApi faceApi;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
@ -207,18 +206,18 @@ public class WorkerInfoController {
|
||||
return Result.success(workerInfoService.attendanceStat(page, map));
|
||||
}
|
||||
|
||||
/**
|
||||
* 人像比对
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "人员管理", operType = "虹软", operDesc = "人像比对")
|
||||
@ApiOperation(value = "人像比对", notes = "人像比对", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "idCardFront", value = "身份证正面图片路径", paramType = "body", dataType = "String"),
|
||||
@ApiImplicitParam(name = "feature", value = "人像照片路径", paramType = "body", dataType = "String")
|
||||
})
|
||||
@PostMapping(value = "/compareFace")
|
||||
public Result<Object> compareFace(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
return Result.success(faceApi.compareFaceFeature(MapUtils.getString(map, "idCardFront"), MapUtils.getString(map, "feature")));
|
||||
}
|
||||
// /**
|
||||
// * 人像比对
|
||||
// * @return
|
||||
// */
|
||||
// @OperLog(operModul = "人员管理", operType = "虹软", operDesc = "人像比对")
|
||||
// @ApiOperation(value = "人像比对", notes = "人像比对", httpMethod = "POST")
|
||||
// @ApiImplicitParams({
|
||||
// @ApiImplicitParam(name = "idCardFront", value = "身份证正面图片路径", paramType = "body", dataType = "String"),
|
||||
// @ApiImplicitParam(name = "feature", value = "人像照片路径", paramType = "body", dataType = "String")
|
||||
// })
|
||||
// @PostMapping(value = "/compareFace")
|
||||
// public Result<Object> compareFace(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
// return Result.success(faceApi.compareFaceFeature(MapUtils.getString(map, "idCardFront"), MapUtils.getString(map, "feature")));
|
||||
// }
|
||||
}
|
||||
|
||||
@ -53,10 +53,10 @@ spring.boot.admin.client.instance.name=dev
|
||||
opencv.filePath=D://opencv//
|
||||
|
||||
#虹软人脸识别
|
||||
arcsoft.appId=13eRvuSeQYts8Tqcrqy4yFyg7h6XQqdUGkjJuh9ct2E2
|
||||
arcsoft.sdkKey=GLc2xHQ7yAwNxrWctSgNgVqwYqMTbz9RKTWWHQNMdJPU
|
||||
arcsoft.linux.sdkKey=
|
||||
arcsoft.dllPath=D:/zhgd3/dll
|
||||
#arcsoft.appId=13eRvuSeQYts8Tqcrqy4yFyg7h6XQqdUGkjJuh9ct2E2
|
||||
#arcsoft.sdkKey=GLc2xHQ7yAwNxrWctSgNgVqwYqMTbz9RKTWWHQNMdJPU
|
||||
#arcsoft.linux.sdkKey=
|
||||
#arcsoft.dllPath=D:/zhgd3/dll
|
||||
|
||||
#关闭页面
|
||||
#magic-api.show-url=false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user