|
@@ -4,12 +4,13 @@ import cn.com.qmth.examcloud.commons.helpers.poi.ExcelReader;
|
|
|
import cn.com.qmth.examcloud.commons.util.FileUtil;
|
|
|
import cn.com.qmth.examcloud.starters.face.verify.FaceVerifyProperties;
|
|
|
import cn.com.qmth.examcloud.starters.face.verify.common.FaceResult;
|
|
|
-import cn.com.qmth.examcloud.starters.face.verify.common.JsonHelper;
|
|
|
import cn.com.qmth.examcloud.starters.face.verify.service.impl.FaceVerifyServiceImpl;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
@@ -105,10 +106,21 @@ public class FaceVerifyTest {
|
|
|
FileUtil.saveImageToFile(capturePhotoUrl, capturePhotoPath);
|
|
|
}
|
|
|
|
|
|
- FaceResult result = faceVerifyService.faceCompareByBaidu(photoFile, capturePhotoFile);
|
|
|
- System.out.println(new JsonHelper().toJson(result));
|
|
|
- if (result.isPass()) {
|
|
|
- passNum.incrementAndGet();
|
|
|
+ String resultPath = dir + "/results/" + DigestUtils.md5Hex(studentId + capturePhotoUrl) + ".log";
|
|
|
+ File resultFile = new File(resultPath);
|
|
|
+ if (resultFile.exists()) {
|
|
|
+ String x = FileUtil.readFile(resultFile).get(0);
|
|
|
+ if (x.contains("true")) {
|
|
|
+ passNum.incrementAndGet();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ FaceResult result = faceVerifyService.faceCompareByBaidu(photoFile, capturePhotoFile);
|
|
|
+ // System.out.println(new JsonHelper().toJson(result));
|
|
|
+ if (result.isPass()) {
|
|
|
+ passNum.incrementAndGet();
|
|
|
+ }
|
|
|
+ String x = result.isPass() + "|" + result.getScore();
|
|
|
+ FileUtil.saveToFile(x.getBytes(StandardCharsets.UTF_8), resultFile);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|