|
@@ -13,6 +13,7 @@ import cn.com.qmth.examcloud.core.oe.student.service.ExamCaptureQueueService;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.service.ExamCaptureService;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
|
|
|
import cn.com.qmth.examcloud.starters.face.verify.model.FaceResult;
|
|
|
+import cn.com.qmth.examcloud.starters.face.verify.model.param.ImageBase64Parm;
|
|
|
import cn.com.qmth.examcloud.starters.face.verify.model.param.ImageParm;
|
|
|
import cn.com.qmth.examcloud.starters.face.verify.model.param.ImageTokenParm;
|
|
|
import cn.com.qmth.examcloud.starters.face.verify.model.param.ImageUrlParm;
|
|
@@ -27,11 +28,12 @@ import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
|
import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
|
|
|
import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
|
|
|
import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
|
|
|
-import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
|
+import cn.com.qmth.examcloud.web.aliyun.OssClient;
|
|
|
import cn.com.qmth.examcloud.web.facepp.FaceppClient;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONException;
|
|
|
import org.slf4j.Logger;
|
|
@@ -74,7 +76,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
private FaceVerifyService faceVerifyService;
|
|
|
|
|
|
@Autowired
|
|
|
- private SystemProperties systemProperties;
|
|
|
+ private OssClient ossClient;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisClient redisClient;
|
|
@@ -198,15 +200,23 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
|
|
|
try {
|
|
|
FaceResult faceResult;
|
|
|
- // String capturePhotoUrl = systemProperties.replaceFileUrlInternalDomain(FileStorageUtil.realPath(fileUrl));
|
|
|
- String capturePhotoUrl = FileStorageUtil.realPath(fileUrl);
|
|
|
- ImageParm imageParm = new ImageUrlParm(capturePhotoUrl);
|
|
|
if (useBaiduApi) {
|
|
|
- // String basePhotoUrl = systemProperties.replaceFileUrlInternalDomain(student.getPhotoPath());
|
|
|
- String basePhotoUrl = student.getPhotoPath();
|
|
|
- faceResult = faceVerifyService.faceCompareByBaidu(new ImageUrlParm(basePhotoUrl), imageParm, baiduExpectFaceCompareScore);
|
|
|
+ String basePhotoUrl = ossClient.valueOfOssFilePath(student.getPhotoPath());
|
|
|
+ byte[] basePhotoBytes = ossClient.download(basePhotoUrl);
|
|
|
+ ImageParm basePhoto = new ImageBase64Parm(Base64.encodeBase64String(basePhotoBytes));
|
|
|
+
|
|
|
+ String capturePhotoUrl = ossClient.valueOfOssFilePath(FileStorageUtil.realPath(fileUrl));
|
|
|
+ byte[] capturePhotoBytes = ossClient.download(capturePhotoUrl);
|
|
|
+ ImageParm capturePhoto = new ImageBase64Parm(Base64.encodeBase64String(capturePhotoBytes));
|
|
|
+
|
|
|
+ faceResult = faceVerifyService.faceCompareByBaidu(basePhoto, capturePhoto, baiduExpectFaceCompareScore);
|
|
|
} else {
|
|
|
- faceResult = faceVerifyService.faceCompareByFacePlus(new ImageTokenParm(student.getFaceToken()), imageParm);
|
|
|
+ ImageParm basePhoto = new ImageTokenParm(student.getFaceToken());
|
|
|
+
|
|
|
+ String capturePhotoUrl = FileStorageUtil.realPath(fileUrl);
|
|
|
+ ImageParm capturePhoto = new ImageUrlParm(capturePhotoUrl);
|
|
|
+
|
|
|
+ faceResult = faceVerifyService.faceCompareByFacePlus(basePhoto, capturePhoto);
|
|
|
}
|
|
|
|
|
|
info.setIsPass(faceResult.isFacePass());
|