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