|
@@ -108,6 +108,7 @@ public class FaceCompareUtil {
|
|
|
//3D信息检测
|
|
//3D信息检测
|
|
|
List<Face3DAngle> face3DAngleList = new ArrayList<Face3DAngle>();
|
|
List<Face3DAngle> face3DAngleList = new ArrayList<Face3DAngle>();
|
|
|
errorCode = faceEngine.getFace3DAngle(face3DAngleList);
|
|
errorCode = faceEngine.getFace3DAngle(face3DAngleList);
|
|
|
|
|
+
|
|
|
if (CollectionUtils.isEmpty(face3DAngleList)) {
|
|
if (CollectionUtils.isEmpty(face3DAngleList)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -137,6 +138,7 @@ public class FaceCompareUtil {
|
|
|
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
|
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
|
|
errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
|
errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
|
|
System.out.println(faceInfoList);
|
|
System.out.println(faceInfoList);
|
|
|
|
|
+
|
|
|
if (faceInfoList.size()>1){
|
|
if (faceInfoList.size()>1){
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -160,11 +162,7 @@ public class FaceCompareUtil {
|
|
|
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
|
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
|
|
errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
|
errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
|
|
System.out.println(faceInfoList);
|
|
System.out.println(faceInfoList);
|
|
|
- //人脸属性检测
|
|
|
|
|
- FunctionConfiguration configuration = new FunctionConfiguration();
|
|
|
|
|
- configuration.setSupportFace3dAngle(true);
|
|
|
|
|
- errorCode = faceEngine.process(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList, configuration);
|
|
|
|
|
- //活体检测
|
|
|
|
|
|
|
+ //活体检测
|
|
|
/*List<LivenessInfo> livenessInfoList = new ArrayList<LivenessInfo>();
|
|
/*List<LivenessInfo> livenessInfoList = new ArrayList<LivenessInfo>();
|
|
|
errorCode = faceEngine.getLiveness(livenessInfoList);
|
|
errorCode = faceEngine.getLiveness(livenessInfoList);
|
|
|
if (CollectionUtils.isEmpty(livenessInfoList)){
|
|
if (CollectionUtils.isEmpty(livenessInfoList)){
|
|
@@ -230,24 +228,33 @@ public class FaceCompareUtil {
|
|
|
} catch (FileNotFoundException e) {
|
|
} catch (FileNotFoundException e) {
|
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
}
|
|
|
- byte[] bytes = new byte[(int) file.length()];
|
|
|
|
|
|
|
+ byte[] bytes = new byte[(int) base.length()];
|
|
|
try {
|
|
try {
|
|
|
fileInputStream.read(bytes);
|
|
fileInputStream.read(bytes);
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
|
|
|
+ }finally {
|
|
|
|
|
+ try {
|
|
|
|
|
+ fileInputStream.close();
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
String s = Base64.getEncoder().encodeToString(bytes);
|
|
String s = Base64.getEncoder().encodeToString(bytes);
|
|
|
|
|
|
|
|
FileInfoEntity fileInfo = uploadFaceFile(s);
|
|
FileInfoEntity fileInfo = uploadFaceFile(s);
|
|
|
|
|
+
|
|
|
faceCompareEntity.setFileId(fileInfo.getId()+"");
|
|
faceCompareEntity.setFileId(fileInfo.getId()+"");
|
|
|
faceCompareEntity.setType(0);
|
|
faceCompareEntity.setType(0);
|
|
|
if (score > 0.8) {
|
|
if (score > 0.8) {
|
|
|
log.info("人脸照片比对通过");
|
|
log.info("人脸照片比对通过");
|
|
|
faceCompareEntity.setResult(1);
|
|
faceCompareEntity.setResult(1);
|
|
|
thirdPartyInterfaceRepository.insert(faceCompareEntity);
|
|
thirdPartyInterfaceRepository.insert(faceCompareEntity);
|
|
|
- base.delete();
|
|
|
|
|
file.delete();
|
|
file.delete();
|
|
|
|
|
+ base.delete();
|
|
|
redis.del(redisCount);
|
|
redis.del(redisCount);
|
|
|
return ResultCode.SUCCESS;
|
|
return ResultCode.SUCCESS;
|
|
|
}
|
|
}
|
|
@@ -256,8 +263,8 @@ public class FaceCompareUtil {
|
|
|
faceCompareEntity.setMessage("验证失败");
|
|
faceCompareEntity.setMessage("验证失败");
|
|
|
faceCompareEntity.setResult(0);
|
|
faceCompareEntity.setResult(0);
|
|
|
thirdPartyInterfaceRepository.insert(faceCompareEntity);
|
|
thirdPartyInterfaceRepository.insert(faceCompareEntity);
|
|
|
- base.delete();
|
|
|
|
|
file.delete();
|
|
file.delete();
|
|
|
|
|
+ base.delete();
|
|
|
return ResultCode.LIVE_VIDEO_INVALID;
|
|
return ResultCode.LIVE_VIDEO_INVALID;
|
|
|
}
|
|
}
|
|
|
|
|
|