包头去掉虹软
This commit is contained in:
parent
89a60c4576
commit
929c1bf3d3
14
pom.xml
14
pom.xml
@ -790,13 +790,13 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- 虹软人脸识别 -->
|
<!-- 虹软人脸识别 -->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.arcsoft.face</groupId>
|
<!-- <groupId>com.arcsoft.face</groupId>-->
|
||||||
<artifactId>arcsoft</artifactId>
|
<!-- <artifactId>arcsoft</artifactId>-->
|
||||||
<version>1.0</version>
|
<!-- <version>1.0</version>-->
|
||||||
<scope>system</scope>
|
<!-- <scope>system</scope>-->
|
||||||
<systemPath>${basedir}/src/main/resources/jar/arcsoft-sdk-face-3.0.0.0.jar</systemPath>
|
<!-- <systemPath>${basedir}/src/main/resources/jar/arcsoft-sdk-face-3.0.0.0.jar</systemPath>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.zxing</groupId>
|
<groupId>com.google.zxing</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
|
|||||||
@ -1,92 +1,92 @@
|
|||||||
package com.zhgd.xmgl.config;
|
//package com.zhgd.xmgl.config;
|
||||||
|
//
|
||||||
import com.arcsoft.face.ActiveFileInfo;
|
//import com.arcsoft.face.ActiveFileInfo;
|
||||||
import com.arcsoft.face.EngineConfiguration;
|
//import com.arcsoft.face.EngineConfiguration;
|
||||||
import com.arcsoft.face.FaceEngine;
|
//import com.arcsoft.face.FaceEngine;
|
||||||
import com.arcsoft.face.FunctionConfiguration;
|
//import com.arcsoft.face.FunctionConfiguration;
|
||||||
import com.arcsoft.face.enums.DetectMode;
|
//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 lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
//import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.CommandLineRunner;
|
//import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.core.annotation.Order;
|
//import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* @program: wisdomSite
|
// * @program: wisdomSite
|
||||||
* @description: 虹软人脸识别插件初始化
|
// * @description: 虹软人脸识别插件初始化
|
||||||
* @author: Mr.Peng
|
// * @author: Mr.Peng
|
||||||
* @create: 2021-04-08 10:18
|
// * @create: 2021-04-08 10:18
|
||||||
**/
|
// **/
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@Order(value = 2)
|
//@Order(value = 2)
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
public class FaceRunner implements CommandLineRunner {
|
//public class FaceRunner implements CommandLineRunner {
|
||||||
|
//
|
||||||
public static FaceEngine faceEngine;
|
// public static FaceEngine faceEngine;
|
||||||
@Value("${arcsoft.appId}")
|
// @Value("${arcsoft.appId}")
|
||||||
private String appId;
|
// private String appId;
|
||||||
@Value("${arcsoft.sdkKey}")
|
// @Value("${arcsoft.sdkKey}")
|
||||||
private String winsSdkKey;
|
// private String winsSdkKey;
|
||||||
@Value("${arcsoft.linux.sdkKey}")
|
// @Value("${arcsoft.linux.sdkKey}")
|
||||||
private String linuxSdkKey;
|
// private String linuxSdkKey;
|
||||||
@Value("${arcsoft.dllPath}")
|
// @Value("${arcsoft.dllPath}")
|
||||||
private String dllPath;
|
// private String dllPath;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void run(String... args) throws Exception {
|
// public void run(String... args) throws Exception {
|
||||||
String os = System.getProperty("os.name");
|
// String os = System.getProperty("os.name");
|
||||||
log.info("服务器系统" + os);
|
// log.info("服务器系统" + os);
|
||||||
//如果是Windows系统
|
// //如果是Windows系统
|
||||||
if (os.toLowerCase().startsWith("win") || os.toLowerCase().startsWith("linux")) {
|
// if (os.toLowerCase().startsWith("win") || os.toLowerCase().startsWith("linux")) {
|
||||||
String sdkKey = "";
|
// String sdkKey = "";
|
||||||
if (os.toLowerCase().startsWith("linux")) {
|
// if (os.toLowerCase().startsWith("linux")) {
|
||||||
sdkKey = linuxSdkKey;
|
// sdkKey = linuxSdkKey;
|
||||||
} else {
|
// } else {
|
||||||
sdkKey = winsSdkKey;
|
// sdkKey = winsSdkKey;
|
||||||
}
|
// }
|
||||||
//log.info(HCNetSDKPath.DLL_PATH+"dll");
|
// //log.info(HCNetSDKPath.DLL_PATH+"dll");
|
||||||
log.info(dllPath);
|
// log.info(dllPath);
|
||||||
faceEngine = new FaceEngine(dllPath);
|
// faceEngine = new FaceEngine(dllPath);
|
||||||
//激活引擎
|
// //激活引擎
|
||||||
int errorCode = faceEngine.activeOnline(appId, sdkKey);
|
// int errorCode = faceEngine.activeOnline(appId, sdkKey);
|
||||||
|
//
|
||||||
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
// if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||||
log.error("引擎激活失败,errorCode:" + errorCode);
|
// log.error("引擎激活失败,errorCode:" + errorCode);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
// ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
||||||
errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
// errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
||||||
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
// if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||||
log.error("获取激活文件信息失败");
|
// log.error("获取激活文件信息失败");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//引擎配置
|
// //引擎配置
|
||||||
EngineConfiguration engineConfiguration = new EngineConfiguration();
|
// EngineConfiguration engineConfiguration = new EngineConfiguration();
|
||||||
engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
|
// engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
|
||||||
engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
|
// engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
|
||||||
engineConfiguration.setDetectFaceMaxNum(10);
|
// engineConfiguration.setDetectFaceMaxNum(10);
|
||||||
engineConfiguration.setDetectFaceScaleVal(16);
|
// engineConfiguration.setDetectFaceScaleVal(16);
|
||||||
//功能配置
|
// //功能配置
|
||||||
FunctionConfiguration functionConfiguration = new FunctionConfiguration();
|
// FunctionConfiguration functionConfiguration = new FunctionConfiguration();
|
||||||
functionConfiguration.setSupportAge(true);
|
// functionConfiguration.setSupportAge(true);
|
||||||
functionConfiguration.setSupportFace3dAngle(true);
|
// functionConfiguration.setSupportFace3dAngle(true);
|
||||||
functionConfiguration.setSupportFaceDetect(true);
|
// functionConfiguration.setSupportFaceDetect(true);
|
||||||
functionConfiguration.setSupportFaceRecognition(true);
|
// functionConfiguration.setSupportFaceRecognition(true);
|
||||||
functionConfiguration.setSupportGender(true);
|
// functionConfiguration.setSupportGender(true);
|
||||||
functionConfiguration.setSupportLiveness(true);
|
// functionConfiguration.setSupportLiveness(true);
|
||||||
functionConfiguration.setSupportIRLiveness(true);
|
// functionConfiguration.setSupportIRLiveness(true);
|
||||||
engineConfiguration.setFunctionConfiguration(functionConfiguration);
|
// engineConfiguration.setFunctionConfiguration(functionConfiguration);
|
||||||
//初始化引擎
|
// //初始化引擎
|
||||||
errorCode = faceEngine.init(engineConfiguration);
|
// errorCode = faceEngine.init(engineConfiguration);
|
||||||
|
//
|
||||||
if (errorCode != ErrorInfo.MOK.getValue()) {
|
// if (errorCode != ErrorInfo.MOK.getValue()) {
|
||||||
log.error("初始化引擎失败");
|
// log.error("初始化引擎失败");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@ -2,10 +2,6 @@ package com.zhgd.xmgl.modules.worker.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.arcsoft.face.FaceFeature;
|
|
||||||
import com.arcsoft.face.FaceInfo;
|
|
||||||
import com.arcsoft.face.FaceSimilar;
|
|
||||||
import com.arcsoft.face.toolkit.ImageInfo;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.zhgd.jeecg.common.api.vo.Result;
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||||
@ -26,7 +22,6 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -37,8 +32,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
//import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
||||||
import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
//import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @program: wisdomSite
|
* @program: wisdomSite
|
||||||
@ -77,41 +72,41 @@ public class UfaceRecognitionController {
|
|||||||
public Result<Map<String, Object>> checkFace(@RequestBody Map<String, Object> map) {
|
public Result<Map<String, Object>> checkFace(@RequestBody Map<String, Object> map) {
|
||||||
Map<String, Object> data = new HashMap<>(16);
|
Map<String, Object> data = new HashMap<>(16);
|
||||||
String os = System.getProperty("os.name");
|
String os = System.getProperty("os.name");
|
||||||
if (Objects.equals(hongruanFacePass,"1")) {
|
// if (Objects.equals(hongruanFacePass,"1")) {
|
||||||
data.put("checkType", "1");
|
data.put("checkType", "1");
|
||||||
data.put("message", "成功");
|
data.put("message", "成功");
|
||||||
return Result.success(data);
|
|
||||||
}
|
|
||||||
if (os.toLowerCase().startsWith(WIN) || os.toLowerCase().startsWith(LINUX)) {
|
|
||||||
String fileUrl = MapUtils.getString(map, "fileUrl");
|
|
||||||
if (StringUtils.isNotEmpty(fileUrl)) {
|
|
||||||
File file = new File(basePath, fileUrl);
|
|
||||||
log.info("basePath:{},fileUrl:{}", basePath, fileUrl);
|
|
||||||
ImageInfo imageInfo = getRGBData(file);
|
|
||||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
|
||||||
int errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
|
||||||
log.info("errorCode:{}", errorCode);
|
|
||||||
if (faceInfoList.size() > 0) {
|
|
||||||
if (faceInfoList.size() > 1) {
|
|
||||||
FileOperation.deleteFile(file);
|
|
||||||
data.put("checkType", "0");
|
|
||||||
data.put("message", "检测到多张人脸");
|
|
||||||
} else {
|
|
||||||
data.put("checkType", "1");
|
|
||||||
data.put("message", "成功");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
FileOperation.deleteFile(file);
|
|
||||||
data.put("checkType", "0");
|
|
||||||
data.put("message", "未检测到人脸");
|
|
||||||
}
|
|
||||||
log.info("{}", faceInfoList);
|
|
||||||
} else {
|
|
||||||
data.put("checkType", "0");
|
|
||||||
data.put("message", "图片路径不正确");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Result.success(data);
|
return Result.success(data);
|
||||||
|
// }
|
||||||
|
// if (os.toLowerCase().startsWith(WIN) || os.toLowerCase().startsWith(LINUX)) {
|
||||||
|
// String fileUrl = MapUtils.getString(map, "fileUrl");
|
||||||
|
// if (StringUtils.isNotEmpty(fileUrl)) {
|
||||||
|
// File file = new File(basePath, fileUrl);
|
||||||
|
// log.info("basePath:{},fileUrl:{}", basePath, fileUrl);
|
||||||
|
// ImageInfo imageInfo = getRGBData(file);
|
||||||
|
// List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||||
|
// int errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
||||||
|
// log.info("errorCode:{}", errorCode);
|
||||||
|
// if (faceInfoList.size() > 0) {
|
||||||
|
// if (faceInfoList.size() > 1) {
|
||||||
|
// FileOperation.deleteFile(file);
|
||||||
|
// data.put("checkType", "0");
|
||||||
|
// data.put("message", "检测到多张人脸");
|
||||||
|
// } else {
|
||||||
|
// data.put("checkType", "1");
|
||||||
|
// data.put("message", "成功");
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// FileOperation.deleteFile(file);
|
||||||
|
// data.put("checkType", "0");
|
||||||
|
// data.put("message", "未检测到人脸");
|
||||||
|
// }
|
||||||
|
// log.info("{}", faceInfoList);
|
||||||
|
// } else {
|
||||||
|
// data.put("checkType", "0");
|
||||||
|
// data.put("message", "图片路径不正确");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return Result.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "海康检测人脸评分", notes = "海康检测人脸评分", httpMethod = "POST")
|
@ApiOperation(value = "海康检测人脸评分", notes = "海康检测人脸评分", httpMethod = "POST")
|
||||||
@ -177,70 +172,71 @@ public class UfaceRecognitionController {
|
|||||||
@PostMapping(value = "/faceComparison")
|
@PostMapping(value = "/faceComparison")
|
||||||
public Result<String> faceComparison(@RequestBody Map<String, Object> map) {
|
public Result<String> faceComparison(@RequestBody Map<String, Object> map) {
|
||||||
Result<String> result = new Result<String>();
|
Result<String> result = new Result<String>();
|
||||||
try {
|
return result.successMsg(MessageUtil.get("optSucess"));
|
||||||
String os = System.getProperty("os.name");
|
// try {
|
||||||
if (os.toLowerCase().startsWith(WIN)) {
|
// String os = System.getProperty("os.name");
|
||||||
String fileUrl = MapUtils.getString(map, "fileUrl");
|
// if (os.toLowerCase().startsWith(WIN)) {
|
||||||
File file = new File(basePath + "/" + fileUrl);
|
// String fileUrl = MapUtils.getString(map, "fileUrl");
|
||||||
//人脸检测
|
// File file = new File(basePath + "/" + fileUrl);
|
||||||
ImageInfo imageInfo = getRGBData(file);
|
// //人脸检测
|
||||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
// ImageInfo imageInfo = getRGBData(file);
|
||||||
int errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
// List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||||
if (faceInfoList == null || faceInfoList.size() == 0) {
|
// int errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
||||||
FileOperation.deleteFile(file);
|
// if (faceInfoList == null || faceInfoList.size() == 0) {
|
||||||
throw new OpenAlertException(MessageUtil.get("faceNotNumErr"));
|
// FileOperation.deleteFile(file);
|
||||||
} else if (faceInfoList.size() > 1) {
|
// throw new OpenAlertException(MessageUtil.get("faceNotNumErr"));
|
||||||
FileOperation.deleteFile(file);
|
// } else if (faceInfoList.size() > 1) {
|
||||||
throw new OpenAlertException(MessageUtil.get("faceMultipleNumErr"));
|
// FileOperation.deleteFile(file);
|
||||||
}
|
// throw new OpenAlertException(MessageUtil.get("faceMultipleNumErr"));
|
||||||
//特征提取
|
// }
|
||||||
FaceFeature faceFeature = new FaceFeature();
|
// //特征提取
|
||||||
errorCode = faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
// FaceFeature faceFeature = new FaceFeature();
|
||||||
log.info("特征值大小:" + faceFeature.getFeatureData().length);
|
// errorCode = faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
||||||
WorkerInfo info = workerInfoService.getById(MapUtils.getString(map, "workerId"));
|
// log.info("特征值大小:" + faceFeature.getFeatureData().length);
|
||||||
//人脸检测2
|
// WorkerInfo info = workerInfoService.getById(MapUtils.getString(map, "workerId"));
|
||||||
ImageInfo imageInfo2 = getRGBData(new File(basePath + "/" + info.getFieldAcquisitionUrl()));
|
// //人脸检测2
|
||||||
List<FaceInfo> faceInfoList2 = new ArrayList<FaceInfo>();
|
// ImageInfo imageInfo2 = getRGBData(new File(basePath + "/" + info.getFieldAcquisitionUrl()));
|
||||||
errorCode = faceEngine.detectFaces(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(), imageInfo.getImageFormat(), faceInfoList2);
|
// List<FaceInfo> faceInfoList2 = new ArrayList<FaceInfo>();
|
||||||
log.info("{}", faceInfoList);
|
// errorCode = faceEngine.detectFaces(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(), imageInfo.getImageFormat(), faceInfoList2);
|
||||||
|
// log.info("{}", faceInfoList);
|
||||||
if (faceInfoList2 == null || faceInfoList2.size() == 0) {
|
//
|
||||||
FileOperation.deleteFile(file);
|
// if (faceInfoList2 == null || faceInfoList2.size() == 0) {
|
||||||
throw new OpenAlertException(MessageUtil.get("faceMismatchErr"));
|
// FileOperation.deleteFile(file);
|
||||||
}
|
// throw new OpenAlertException(MessageUtil.get("faceMismatchErr"));
|
||||||
//特征提取2
|
// }
|
||||||
FaceFeature faceFeature2 = new FaceFeature();
|
// //特征提取2
|
||||||
errorCode = faceEngine.extractFaceFeature(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(), imageInfo.getImageFormat(), faceInfoList2.get(0), faceFeature2);
|
// FaceFeature faceFeature2 = new FaceFeature();
|
||||||
log.info("特征值大小:" + faceFeature2.getFeatureData().length);
|
// errorCode = faceEngine.extractFaceFeature(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(), imageInfo.getImageFormat(), faceInfoList2.get(0), faceFeature2);
|
||||||
//特征比对
|
// log.info("特征值大小:" + faceFeature2.getFeatureData().length);
|
||||||
FaceFeature targetFaceFeature = new FaceFeature();
|
// //特征比对
|
||||||
targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
|
// FaceFeature targetFaceFeature = new FaceFeature();
|
||||||
FaceFeature sourceFaceFeature = new FaceFeature();
|
// targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
|
||||||
sourceFaceFeature.setFeatureData(faceFeature2.getFeatureData());
|
// FaceFeature sourceFaceFeature = new FaceFeature();
|
||||||
FaceSimilar faceSimilar = new FaceSimilar();
|
// sourceFaceFeature.setFeatureData(faceFeature2.getFeatureData());
|
||||||
|
// FaceSimilar faceSimilar = new FaceSimilar();
|
||||||
errorCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature, faceSimilar);
|
//
|
||||||
log.info("相似度:" + faceSimilar.getScore());
|
// errorCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature, faceSimilar);
|
||||||
Integer score = MapUtils.getInteger(map, "faceScore");
|
// log.info("相似度:" + faceSimilar.getScore());
|
||||||
int abc = Double.valueOf(faceSimilar.getScore() * 100).intValue();
|
// Integer score = MapUtils.getInteger(map, "faceScore");
|
||||||
if (abc >= score) {
|
// int abc = Double.valueOf(faceSimilar.getScore() * 100).intValue();
|
||||||
result.successMsg(MessageUtil.get("optSucess"));
|
// if (abc >= score) {
|
||||||
} else {
|
// result.successMsg(MessageUtil.get("optSucess"));
|
||||||
FileOperation.deleteFile(file);
|
// } else {
|
||||||
throw new OpenAlertException(MessageUtil.get("faceMismatchErr"));
|
// FileOperation.deleteFile(file);
|
||||||
}
|
// throw new OpenAlertException(MessageUtil.get("faceMismatchErr"));
|
||||||
} else {
|
// }
|
||||||
log.info("当前操作系统不是window系统");
|
// } else {
|
||||||
result.successMsg(MessageUtil.get("optSucess"));
|
// log.info("当前操作系统不是window系统");
|
||||||
}
|
// result.successMsg(MessageUtil.get("optSucess"));
|
||||||
} catch (OpenAlertException e) {
|
// }
|
||||||
//log.error("error:",e);
|
// } catch (OpenAlertException e) {
|
||||||
result.error500(e.getMessage());
|
// //log.error("error:",e);
|
||||||
} catch (Exception e) {
|
// result.error500(e.getMessage());
|
||||||
log.error("error:", e);
|
// } catch (Exception e) {
|
||||||
log.info(e.getMessage());
|
// log.error("error:", e);
|
||||||
result.error500(MessageUtil.get("failErr"));
|
// log.info(e.getMessage());
|
||||||
}
|
// result.error500(MessageUtil.get("failErr"));
|
||||||
return result;
|
// }
|
||||||
|
// return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,10 @@ import cn.hutool.core.io.FileUtil;
|
|||||||
import cn.xuyanwu.spring.file.storage.FileInfo;
|
import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.arcsoft.face.FaceFeature;
|
//import com.arcsoft.face.FaceFeature;
|
||||||
import com.arcsoft.face.FaceInfo;
|
//import com.arcsoft.face.FaceInfo;
|
||||||
import com.arcsoft.face.FaceSimilar;
|
//import com.arcsoft.face.FaceSimilar;
|
||||||
import com.arcsoft.face.toolkit.ImageInfo;
|
//import com.arcsoft.face.toolkit.ImageInfo;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@ -58,8 +58,8 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
//import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
||||||
import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
//import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 人员考勤
|
* @Description: 人员考勤
|
||||||
@ -1283,14 +1283,14 @@ status 状态码 String 1表示成功;其余表示失败
|
|||||||
file = Base64Util.convertBase64ToFile(personImage, basePath, UUID.randomUUID().toString() + ".jpg");
|
file = Base64Util.convertBase64ToFile(personImage, basePath, UUID.randomUUID().toString() + ".jpg");
|
||||||
log.info("--图片--:" + file.getAbsolutePath() + "--名称--" + file.getName());
|
log.info("--图片--:" + file.getAbsolutePath() + "--名称--" + file.getName());
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
FaceFeature oldFaceFeature = getFaceFeaByhongruan(file);
|
// FaceFeature oldFaceFeature = getFaceFeaByhongruan(file);
|
||||||
List<WorkerInfo> tempList = new ArrayList<>();
|
List<WorkerInfo> tempList = new ArrayList<>();
|
||||||
for (WorkerInfo workerInfo : list) {
|
for (WorkerInfo workerInfo : list) {
|
||||||
int faceScore = getFaceSorce(workerInfo, oldFaceFeature);
|
// int faceScore = getFaceSorce(workerInfo, oldFaceFeature);
|
||||||
if (faceScore >= ufaceSorce) {
|
// if (faceScore >= ufaceSorce) {
|
||||||
workerInfo.setFaceScore(faceScore);
|
// workerInfo.setFaceScore(faceScore);
|
||||||
tempList.add(workerInfo);
|
// tempList.add(workerInfo);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
Collections.sort(tempList, new Comparator<WorkerInfo>() {
|
Collections.sort(tempList, new Comparator<WorkerInfo>() {
|
||||||
@Override
|
@Override
|
||||||
@ -1323,18 +1323,18 @@ status 状态码 String 1表示成功;其余表示失败
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFaceSorce(WorkerInfo workerInfo, FaceFeature oldFaceFeature) {
|
// public int getFaceSorce(WorkerInfo workerInfo, FaceFeature oldFaceFeature) {
|
||||||
if (workerInfo != null && workerInfo.getFeahongruan() != null) {
|
// if (workerInfo != null && workerInfo.getFeahongruan() != null) {
|
||||||
FaceFeature infoFaceFeature = new FaceFeature();
|
// FaceFeature infoFaceFeature = new FaceFeature();
|
||||||
infoFaceFeature.setFeatureData(workerInfo.getFeahongruan());
|
// infoFaceFeature.setFeatureData(workerInfo.getFeahongruan());
|
||||||
FaceSimilar faceSimilar = new FaceSimilar();
|
// FaceSimilar faceSimilar = new FaceSimilar();
|
||||||
faceEngine.compareFaceFeature(oldFaceFeature, infoFaceFeature, faceSimilar);
|
// faceEngine.compareFaceFeature(oldFaceFeature, infoFaceFeature, faceSimilar);
|
||||||
int faceScore = Double.valueOf(faceSimilar.getScore() * 100).intValue();
|
// int faceScore = Double.valueOf(faceSimilar.getScore() * 100).intValue();
|
||||||
return faceScore;
|
// return faceScore;
|
||||||
} else {
|
// } else {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 虹软获取特征值
|
* 虹软获取特征值
|
||||||
@ -1342,15 +1342,15 @@ status 状态码 String 1表示成功;其余表示失败
|
|||||||
* @param
|
* @param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public FaceFeature getFaceFeaByhongruan(File file) {
|
// public FaceFeature getFaceFeaByhongruan(File file) {
|
||||||
ImageInfo imageInfo = getRGBData(file);
|
// ImageInfo imageInfo = getRGBData(file);
|
||||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
// List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||||
faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
// faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
||||||
FaceFeature faceFeature = new FaceFeature();
|
// FaceFeature faceFeature = new FaceFeature();
|
||||||
if (faceInfoList.size() > 0) {
|
// if (faceInfoList.size() > 0) {
|
||||||
faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
// faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
||||||
}
|
// }
|
||||||
return faceFeature;
|
// return faceFeature;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
package com.zhgd.xmgl.modules.worker.service.impl;
|
package com.zhgd.xmgl.modules.worker.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import com.arcsoft.face.FaceFeature;
|
//import com.arcsoft.face.FaceFeature;
|
||||||
import com.arcsoft.face.FaceInfo;
|
//import com.arcsoft.face.FaceInfo;
|
||||||
import com.arcsoft.face.FaceSimilar;
|
//import com.arcsoft.face.FaceSimilar;
|
||||||
import com.arcsoft.face.toolkit.ImageInfo;
|
//import com.arcsoft.face.toolkit.ImageInfo;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.zhgd.xmgl.modules.basicdata.service.UploadFileService;
|
import com.zhgd.xmgl.modules.basicdata.service.UploadFileService;
|
||||||
@ -23,13 +24,13 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
//import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
||||||
import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
//import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 人员照片库
|
* @Description: 人员照片库
|
||||||
* @author: pds
|
* @author: pds
|
||||||
* @date: 2021-09-23
|
* @date: 2021-09-23
|
||||||
* @version: V1.0
|
* @version: V1.0
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@ -73,7 +74,7 @@ public class WorkerImageLibraryServiceImpl extends ServiceImpl<WorkerImageLibrar
|
|||||||
if(imageUrl!=null){
|
if(imageUrl!=null){
|
||||||
if(!imageUrl.startsWith(HTTP)){
|
if(!imageUrl.startsWith(HTTP)){
|
||||||
File infoFile=new File(basePath+"/"+workerImageLibrary.getImageUrl());
|
File infoFile=new File(basePath+"/"+workerImageLibrary.getImageUrl());
|
||||||
workerImageLibrary.setFeahongruan(getFaceFeaByhongruan(infoFile).getFeatureData());
|
// workerImageLibrary.setFeahongruan(getFaceFeaByhongruan(infoFile).getFeatureData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
workerImageLibrary.setProjectSn(ufaceDev.getProjectSn());
|
workerImageLibrary.setProjectSn(ufaceDev.getProjectSn());
|
||||||
@ -102,16 +103,16 @@ public class WorkerImageLibraryServiceImpl extends ServiceImpl<WorkerImageLibrar
|
|||||||
File file = new File(basePath + "/" + fileUrl);
|
File file = new File(basePath + "/" + fileUrl);
|
||||||
List<WorkerImageLibrary> tempList=new ArrayList<>();
|
List<WorkerImageLibrary> tempList=new ArrayList<>();
|
||||||
if(file!=null){
|
if(file!=null){
|
||||||
FaceFeature oldFaceFeature=getFaceFeaByhongruan(file);
|
// FaceFeature oldFaceFeature=getFaceFeaByhongruan(file);
|
||||||
|
|
||||||
for(WorkerImageLibrary workerInfo:list){
|
// for(WorkerImageLibrary workerInfo:list){
|
||||||
int faceScore=getFaceSorce(workerInfo,oldFaceFeature);
|
// int faceScore=getFaceSorce(workerInfo,oldFaceFeature);
|
||||||
if(faceScore>=60){
|
// if(faceScore>=60){
|
||||||
workerInfo.setFaceScore(faceScore);
|
// workerInfo.setFaceScore(faceScore);
|
||||||
tempList.add(workerInfo);
|
// tempList.add(workerInfo);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
Collections.sort(tempList , new Comparator<WorkerImageLibrary>() {
|
Collections.sort(tempList, new Comparator<WorkerImageLibrary>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(WorkerImageLibrary o1, WorkerImageLibrary o2) {
|
public int compare(WorkerImageLibrary o1, WorkerImageLibrary o2) {
|
||||||
Integer o1Value = o1.getFaceScore();
|
Integer o1Value = o1.getFaceScore();
|
||||||
@ -123,27 +124,27 @@ public class WorkerImageLibraryServiceImpl extends ServiceImpl<WorkerImageLibrar
|
|||||||
|
|
||||||
return tempList;
|
return tempList;
|
||||||
}
|
}
|
||||||
public int getFaceSorce(WorkerImageLibrary workerImageLibrary,FaceFeature oldFaceFeature){
|
// public int getFaceSorce(WorkerImageLibrary workerImageLibrary,FaceFeature oldFaceFeature){
|
||||||
if(workerImageLibrary!=null&&workerImageLibrary.getFeahongruan()!=null) {
|
// if(workerImageLibrary!=null&&workerImageLibrary.getFeahongruan()!=null) {
|
||||||
FaceFeature infoFaceFeature = new FaceFeature();
|
// FaceFeature infoFaceFeature = new FaceFeature();
|
||||||
infoFaceFeature.setFeatureData(workerImageLibrary.getFeahongruan());
|
// infoFaceFeature.setFeatureData(workerImageLibrary.getFeahongruan());
|
||||||
FaceSimilar faceSimilar = new FaceSimilar();
|
// FaceSimilar faceSimilar = new FaceSimilar();
|
||||||
faceEngine.compareFaceFeature(oldFaceFeature, infoFaceFeature, faceSimilar);
|
// faceEngine.compareFaceFeature(oldFaceFeature, infoFaceFeature, faceSimilar);
|
||||||
int faceScore = Double.valueOf(faceSimilar.getScore() * 100).intValue();
|
// int faceScore = Double.valueOf(faceSimilar.getScore() * 100).intValue();
|
||||||
return faceScore;
|
// return faceScore;
|
||||||
}else{
|
// }else{
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public FaceFeature getFaceFeaByhongruan(File file){
|
// public FaceFeature getFaceFeaByhongruan(File file){
|
||||||
ImageInfo imageInfo = getRGBData(file);
|
// ImageInfo imageInfo = getRGBData(file);
|
||||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
// List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||||
faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
// faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
||||||
FaceFeature faceFeature = new FaceFeature();
|
// FaceFeature faceFeature = new FaceFeature();
|
||||||
if(faceInfoList.size()>0) {
|
// if(faceInfoList.size()>0) {
|
||||||
faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
// faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
||||||
}
|
// }
|
||||||
return faceFeature;
|
// return faceFeature;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package com.zhgd.xmgl.modules.worker.service.impl;
|
package com.zhgd.xmgl.modules.worker.service.impl;
|
||||||
|
|
||||||
import com.arcsoft.face.FaceFeature;
|
//import com.arcsoft.face.FaceFeature;
|
||||||
import com.arcsoft.face.FaceInfo;
|
//import com.arcsoft.face.FaceInfo;
|
||||||
import com.arcsoft.face.toolkit.ImageInfo;
|
//import com.arcsoft.face.toolkit.ImageInfo;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||||
@ -18,8 +19,8 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
//import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
||||||
import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
//import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 人员现场采集照特征值
|
* @Description: 人员现场采集照特征值
|
||||||
@ -47,7 +48,7 @@ public class WorkerPhotoFeaturesServiceImpl extends ServiceImpl<WorkerPhotoFeatu
|
|||||||
if (!workerInfo.getFieldAcquisitionUrl().equals(workerPhotoFeatures.getImageUrl())) {
|
if (!workerInfo.getFieldAcquisitionUrl().equals(workerPhotoFeatures.getImageUrl())) {
|
||||||
if (workerInfo.getFieldAcquisitionUrl().startsWith(HTTP)) {
|
if (workerInfo.getFieldAcquisitionUrl().startsWith(HTTP)) {
|
||||||
File infoFile = new File(basePath + "/" + workerInfo.getFieldAcquisitionUrl());
|
File infoFile = new File(basePath + "/" + workerInfo.getFieldAcquisitionUrl());
|
||||||
workerPhotoFeatures.setFeahongruan(getFaceFeaByhongruan(infoFile));
|
// workerPhotoFeatures.setFeahongruan(getFaceFeaByhongruan(infoFile));
|
||||||
}
|
}
|
||||||
workerPhotoFeaturesMapper.updateById(workerPhotoFeatures);
|
workerPhotoFeaturesMapper.updateById(workerPhotoFeatures);
|
||||||
|
|
||||||
@ -57,24 +58,24 @@ public class WorkerPhotoFeaturesServiceImpl extends ServiceImpl<WorkerPhotoFeatu
|
|||||||
tempWorkerPhotoFeatures.setPersonSn(workerInfo.getPersonSn());
|
tempWorkerPhotoFeatures.setPersonSn(workerInfo.getPersonSn());
|
||||||
tempWorkerPhotoFeatures.setImageUrl(workerInfo.getFieldAcquisitionUrl());
|
tempWorkerPhotoFeatures.setImageUrl(workerInfo.getFieldAcquisitionUrl());
|
||||||
File infoFile = new File(basePath + "/" + workerInfo.getFieldAcquisitionUrl());
|
File infoFile = new File(basePath + "/" + workerInfo.getFieldAcquisitionUrl());
|
||||||
tempWorkerPhotoFeatures.setFeahongruan(getFaceFeaByhongruan(infoFile));
|
// tempWorkerPhotoFeatures.setFeahongruan(getFaceFeaByhongruan(infoFile));
|
||||||
workerPhotoFeaturesMapper.insert(tempWorkerPhotoFeatures);
|
workerPhotoFeaturesMapper.insert(tempWorkerPhotoFeatures);
|
||||||
|
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("error:", e);
|
log.error("error:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte[] getFaceFeaByhongruan(File file){
|
// public byte[] getFaceFeaByhongruan(File file){
|
||||||
ImageInfo imageInfo = getRGBData(file);
|
// ImageInfo imageInfo = getRGBData(file);
|
||||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
// List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||||
faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
// faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
||||||
FaceFeature faceFeature = new FaceFeature();
|
// FaceFeature faceFeature = new FaceFeature();
|
||||||
if(faceInfoList.size()>0) {
|
// if(faceInfoList.size()>0) {
|
||||||
faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
// faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
||||||
}
|
// }
|
||||||
return faceFeature.getFeatureData();
|
// return faceFeature.getFeatureData();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user