|
|
@@ -14,10 +14,8 @@ import com.ktg.common.exception.user.CaptchaException;
|
|
|
import com.ktg.common.exception.user.CaptchaExpireException;
|
|
|
import com.ktg.common.exception.user.UserPasswordNotMatchException;
|
|
|
import com.ktg.common.utils.*;
|
|
|
-import com.ktg.common.utils.face.FaceCutUtil;
|
|
|
import com.ktg.common.utils.face.FaceMatchUtil;
|
|
|
import com.ktg.common.utils.ip.IpUtils;
|
|
|
-import com.ktg.common.vo.FaceCutVO;
|
|
|
import com.ktg.common.vo.FaceMatchVO;
|
|
|
import com.ktg.common.vo.VerificationVO;
|
|
|
import com.ktg.framework.manager.AsyncManager;
|
|
|
@@ -43,7 +41,6 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
@@ -260,40 +257,15 @@ public class SysLoginService {
|
|
|
Assert.isFalse(list.isEmpty(), "人脸库中暂无您的人脸信息!");
|
|
|
List<String> collect = list.stream().map(SysUserCharacteristic::getContent).collect(Collectors.toList());
|
|
|
// 通过人脸获取最相似的用户
|
|
|
- FaceCutVO faceCutVO = null;
|
|
|
- FaceMatchVO faceMatchVO;
|
|
|
- try {
|
|
|
- // 记录开始时间
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
- faceCutVO = FaceCutUtil.imageFaceDetection(file, 0L, null);
|
|
|
-
|
|
|
- // 记录结束时间
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
- // 计算时间差(毫秒)
|
|
|
- long duration = endTime - startTime;
|
|
|
- System.out.println("Execution time in milliseconds: " + duration);
|
|
|
-
|
|
|
-
|
|
|
- // 记录开始时间
|
|
|
- long startTime1 = System.currentTimeMillis();
|
|
|
- faceMatchVO = FaceMatchUtil.faceRecognitionComparison(file, new HashSet<>(collect));
|
|
|
- // 记录结束时间
|
|
|
- long endTime1 = System.currentTimeMillis();
|
|
|
- // 计算时间差(毫秒)
|
|
|
- long duration1 = endTime1 - startTime1;
|
|
|
- System.out.println("Execution time in milliseconds: " + duration1);
|
|
|
- Assert.notNull(faceMatchVO, "无法根据人脸确定您的身份,请通过其它方式登录!");
|
|
|
- } finally {
|
|
|
- // 删除刚刚上传的文件信息
|
|
|
- File file1 = new File(faceCutVO.getContent());
|
|
|
- if (!file1.delete()) {
|
|
|
- log.error("面部临时裁剪文件删除失败: " + faceCutVO.getContent());
|
|
|
- }
|
|
|
- File file2 = new File(faceCutVO.getImagePath());
|
|
|
- if (!file2.delete()) {
|
|
|
- log.error("img文件删除失败: " + faceCutVO.getImagePath());
|
|
|
- }
|
|
|
- }
|
|
|
+ // 记录开始时间
|
|
|
+ long startTime1 = System.currentTimeMillis();
|
|
|
+ FaceMatchVO faceMatchVO = FaceMatchUtil.faceRecognitionComparison(file, new HashSet<>(collect));
|
|
|
+ // 记录结束时间
|
|
|
+ long endTime1 = System.currentTimeMillis();
|
|
|
+ // 计算时间差(毫秒)
|
|
|
+ long duration1 = endTime1 - startTime1;
|
|
|
+ System.out.println("Execution time in milliseconds: " + duration1);
|
|
|
+ Assert.notNull(faceMatchVO, "无法根据人脸确定您的身份,请通过其它方式登录!");
|
|
|
String okFace = faceMatchVO.getContent();
|
|
|
SysUserCharacteristic one = iSysUserCharacteristicService.getOne(Wrappers.<SysUserCharacteristic>lambdaQuery()
|
|
|
.eq(SysUserCharacteristic::getContent, okFace)
|
|
|
@@ -308,6 +280,4 @@ public class SysLoginService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|