|
@@ -55,7 +55,7 @@ public class FaceApi {
|
|
|
|
|
|
|
|
@ApiOperation("根据照片文件获取特征码")
|
|
@ApiOperation("根据照片文件获取特征码")
|
|
|
@PostMapping("/faceFeature")
|
|
@PostMapping("/faceFeature")
|
|
|
- public ResultData faceFeature(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
|
|
|
|
+ public ResultData faceFeature(@RequestParam("file") MultipartFile file) {
|
|
|
ImageInfo imageInfo;
|
|
ImageInfo imageInfo;
|
|
|
File file1 = null;
|
|
File file1 = null;
|
|
|
try {
|
|
try {
|
|
@@ -139,20 +139,24 @@ public class FaceApi {
|
|
|
if(null==faceInfos || faceInfos.isEmpty()){
|
|
if(null==faceInfos || faceInfos.isEmpty()){
|
|
|
return ResultData.fail("识别中");
|
|
return ResultData.fail("识别中");
|
|
|
}
|
|
}
|
|
|
- FaceFeature faceFeature = faceService.faceFeature(imageInfo, faceInfos);
|
|
|
|
|
- if(StringUtils.isNotNull(faceFeature.getFeatureData())){
|
|
|
|
|
- R<LabStudentsInfo> info = remoteStudentsService.getInfo(faceCompare.getUserId());
|
|
|
|
|
- if (info.getCode() == 200 && info.getData() != null) {
|
|
|
|
|
- FaceFeature target = new FaceFeature(info.getData().getFaceFeature());
|
|
|
|
|
- FaceFeature source = new FaceFeature(faceFeature.getFeatureData());
|
|
|
|
|
- Boolean bool = faceService.compare(target, source);
|
|
|
|
|
- logger.info("【人脸识别】 识别的用户 userId = {}, 人脸对比结果: {}", faceCompare.getUserId(), bool);
|
|
|
|
|
- return ResultData.result(bool, () -> "人脸对比不符!");
|
|
|
|
|
- } else {
|
|
|
|
|
- return ResultData.fail("未获取到对比数据!:" + info.getMsg());
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ FaceFeature faceFeature = faceService.faceFeature(imageInfo, faceInfos);
|
|
|
|
|
+ if(StringUtils.isNotNull(faceFeature.getFeatureData())){
|
|
|
|
|
+ R<LabStudentsInfo> info = remoteStudentsService.getInfo(faceCompare.getUserId());
|
|
|
|
|
+ if (info.getCode() == 200 && info.getData() != null) {
|
|
|
|
|
+ FaceFeature target = new FaceFeature(info.getData().getFaceFeature());
|
|
|
|
|
+ FaceFeature source = new FaceFeature(faceFeature.getFeatureData());
|
|
|
|
|
+ Boolean bool = faceService.compare(target, source);
|
|
|
|
|
+ logger.info("【人脸识别】 识别的用户 userId = {}, 人脸对比结果: {}", faceCompare.getUserId(), bool);
|
|
|
|
|
+ return ResultData.result(bool, () -> "人脸对比不符!");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return ResultData.fail("未获取到对比数据!:" + info.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return ResultData.fail("未获取到特征码!");
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
- return ResultData.fail("未获取到特征码!");
|
|
|
|
|
|
|
+ }catch (Exception ex){
|
|
|
|
|
+ return ResultData.fail("人脸特征提取失败!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|