|
|
@@ -119,6 +119,10 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
return ResultCode.FACEAUTH_FAIL;
|
|
|
}
|
|
|
|
|
|
+ if (imageSingle(base)){
|
|
|
+ return ResultCode.SINGLE_PERSON;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
FileInfoEntity fileInfo = uploadFaceFile(base64);
|
|
|
boolean redisFlag = (count != null && count >= 2);
|
|
|
@@ -235,6 +239,9 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
log.info("base64转图片异常");
|
|
|
return ResultCode.FACEAUTH_FAIL;
|
|
|
}
|
|
|
+ if (imageSingle(base)){
|
|
|
+ return ResultCode.SINGLE_PERSON;
|
|
|
+ }
|
|
|
boolean redisFlag = (count != null && count >= 2);
|
|
|
if (flag) {
|
|
|
//说明是客户经理
|
|
|
@@ -391,6 +398,61 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验图片的当事人是否为一个
|
|
|
+ * @param base
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean imageSingle(File base) {
|
|
|
+ //从官网获取
|
|
|
+ FaceEngine faceEngine = new FaceEngine(libpath);
|
|
|
+ //激活引擎
|
|
|
+ int errorCode = faceEngine.activeOnline(appid, sdkkey);
|
|
|
+ if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
+ base.delete();
|
|
|
+ throw new RuntimeException("引擎激活失败");
|
|
|
+ }
|
|
|
+ ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
|
|
+ errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
|
|
+ if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
+ base.delete();
|
|
|
+ throw new RuntimeException("获取激活文件信息失败");
|
|
|
+ }
|
|
|
+ //引擎配置
|
|
|
+ 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()) {
|
|
|
+ base.delete();
|
|
|
+ throw new RuntimeException("初始化引擎失败");
|
|
|
+ }
|
|
|
+ //人脸检测
|
|
|
+ ImageInfo imageInfo = getRGBData(base);
|
|
|
+ List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
|
|
+ errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
|
|
+ System.out.println(faceInfoList);
|
|
|
+ if (faceInfoList.size()>1){
|
|
|
+ System.out.println("请当事人单独认证");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 虹软的人脸照片比对
|