|
|
@@ -320,7 +320,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
* @param count redis当中的次数
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean compareImage(File base, Integer id, String redisCount, Integer count) {
|
|
|
+ public ResultCode compareImage(File base, Integer id, String redisCount, Integer count) {
|
|
|
//从官网获取
|
|
|
FaceEngine faceEngine = new FaceEngine(LIBPATH);
|
|
|
//激活引擎
|
|
|
@@ -378,8 +378,45 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
if (pitch >= 10 || yaw >= 10) {
|
|
|
//照片不符合标准
|
|
|
log.info("图片不符合标准");
|
|
|
+
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ String imgStr = Img2Base64Util.getImgStr(base.getPath());
|
|
|
+ uploadFile(imgStr);
|
|
|
+ System.err.println(imgStr);
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+
|
|
|
+ return ResultCode.IMAGE_NOT_STANDARD;
|
|
|
+ }
|
|
|
+ //活体检测
|
|
|
+ /*List<LivenessInfo> livenessInfoList = new ArrayList<LivenessInfo>();
|
|
|
+ errorCode = faceEngine.getLiveness(livenessInfoList);
|
|
|
+ if (CollectionUtils.isEmpty(livenessInfoList)){
|
|
|
+ log.info("活体验证失败");
|
|
|
return false;
|
|
|
}
|
|
|
+ System.out.println("活体:" + livenessInfoList.get(0).getLiveness());
|
|
|
+
|
|
|
+ //IR属性处理
|
|
|
+ ImageInfo imageInfoGray = getGrayData(base);
|
|
|
+ List<FaceInfo> faceInfoListGray = new ArrayList<FaceInfo>();
|
|
|
+ errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoListGray);
|
|
|
+
|
|
|
+ FunctionConfiguration configuration2 = new FunctionConfiguration();
|
|
|
+ configuration2.setSupportIRLiveness(true);
|
|
|
+ errorCode = faceEngine.processIr(imageInfoGray.getImageData(), imageInfoGray.getWidth(), imageInfoGray.getHeight(), imageInfoGray.getImageFormat(), faceInfoListGray, configuration2);
|
|
|
+ //IR活体检测
|
|
|
+ List<IrLivenessInfo> irLivenessInfo = new ArrayList<>();
|
|
|
+ errorCode = faceEngine.getLivenessIr(irLivenessInfo);
|
|
|
+ if (CollectionUtils.isEmpty(irLivenessInfo)){
|
|
|
+ log.info("活体验证失败");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ System.out.println("IR活体:" + irLivenessInfo.get(0).getLiveness());*/
|
|
|
+
|
|
|
+
|
|
|
//特征提取
|
|
|
FaceFeature faceFeature = new FaceFeature();
|
|
|
errorCode = faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
|
|
@@ -413,7 +450,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
log.info("人脸照片比对通过");
|
|
|
base.delete();
|
|
|
file.delete();
|
|
|
- return true;
|
|
|
+ return ResultCode.SUCCESS;
|
|
|
}
|
|
|
if (count == null) {
|
|
|
redis.set(redisCount, 1, 30, TimeUnit.MINUTES);
|
|
|
@@ -423,7 +460,7 @@ public class NotaryDomainImpl implements NotaryDomain {
|
|
|
log.info("人脸照片比对未通过");
|
|
|
base.delete();
|
|
|
file.delete();
|
|
|
- return false;
|
|
|
+ return ResultCode.LIVE_VIDEO_INVALID;
|
|
|
}
|
|
|
|
|
|
|