|
@@ -147,6 +147,8 @@ import * as faceapi from "face-api.js";
|
|
import MD5 from "js-md5";
|
|
import MD5 from "js-md5";
|
|
// import introJs from "intro.js";
|
|
// import introJs from "intro.js";
|
|
import throttle from "lodash-es/throttle";
|
|
import throttle from "lodash-es/throttle";
|
|
|
|
+import { createNamespacedHelpers } from "vuex";
|
|
|
|
+const { mapMutations } = createNamespacedHelpers("examingHomeModule");
|
|
|
|
|
|
// models path
|
|
// models path
|
|
const modelsPath = "/models/20190620/";
|
|
const modelsPath = "/models/20190620/";
|
|
@@ -294,6 +296,7 @@ export default {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
async created() {
|
|
async created() {
|
|
|
|
+ this.updateIsDoingFaceLiveness(true);
|
|
// console.log(faceapi);
|
|
// console.log(faceapi);
|
|
// console.log(faceapi.nets.tinyFaceDetector);
|
|
// console.log(faceapi.nets.tinyFaceDetector);
|
|
this.$Spin.show({});
|
|
this.$Spin.show({});
|
|
@@ -313,6 +316,7 @@ export default {
|
|
this.run();
|
|
this.run();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ ...mapMutations(["updateIsDoingFaceLiveness"]),
|
|
async fetchData() {
|
|
async fetchData() {
|
|
const examRecordDataId = this.$route.params.examRecordDataId;
|
|
const examRecordDataId = this.$route.params.examRecordDataId;
|
|
// 失败了再取
|
|
// 失败了再取
|
|
@@ -340,6 +344,7 @@ export default {
|
|
this.faceBiopsyInfo = faceBiopsyInfo;
|
|
this.faceBiopsyInfo = faceBiopsyInfo;
|
|
},
|
|
},
|
|
async closeMe() {
|
|
async closeMe() {
|
|
|
|
+ this.updateIsDoingFaceLiveness(false);
|
|
const faceLiveResultData = await this.$httpPostRetry(
|
|
const faceLiveResultData = await this.$httpPostRetry(
|
|
"/api/ecs_oe_student/faceBiopsy/saveFaceBiopsyResult",
|
|
"/api/ecs_oe_student/faceBiopsy/saveFaceBiopsyResult",
|
|
this.finalResult
|
|
this.finalResult
|
|
@@ -364,6 +369,7 @@ export default {
|
|
this.behavingStartDate = null;
|
|
this.behavingStartDate = null;
|
|
this.happyFailedTimes = 0;
|
|
this.happyFailedTimes = 0;
|
|
this.singleFaceFailedTimes = 0;
|
|
this.singleFaceFailedTimes = 0;
|
|
|
|
+ this.totalDetectTimes = 0;
|
|
const steps = this.faceBiopsyInfo.verifySteps
|
|
const steps = this.faceBiopsyInfo.verifySteps
|
|
// .filter(s => ["HAPPY", "SERIOUS"].includes(s.action))
|
|
// .filter(s => ["HAPPY", "SERIOUS"].includes(s.action))
|
|
.map(s => {
|
|
.map(s => {
|
|
@@ -551,6 +557,7 @@ export default {
|
|
// if (result.length === 0) {
|
|
// if (result.length === 0) {
|
|
// document.body.appendChild(canvas2);
|
|
// document.body.appendChild(canvas2);
|
|
// }
|
|
// }
|
|
|
|
+ this.totalDetectTimes++;
|
|
} else {
|
|
} else {
|
|
result = await faceapi
|
|
result = await faceapi
|
|
// .detectSingleFace(videoEl, options)
|
|
// .detectSingleFace(videoEl, options)
|
|
@@ -570,7 +577,10 @@ export default {
|
|
// 只有不是调整人脸距离的时候增加失败次数
|
|
// 只有不是调整人脸距离的时候增加失败次数
|
|
this.singleFaceFailedTimes++;
|
|
this.singleFaceFailedTimes++;
|
|
}
|
|
}
|
|
- if (this.singleFaceFailedTimes >= 5) {
|
|
|
|
|
|
+ if (
|
|
|
|
+ this.singleFaceFailedTimes >= 3 &&
|
|
|
|
+ this.singleFaceFailedTimes / this.totalDetectTimes >= 0.2
|
|
|
|
+ ) {
|
|
this.corFinalResult.result = false;
|
|
this.corFinalResult.result = false;
|
|
this.corFinalResult.errorMsg =
|
|
this.corFinalResult.errorMsg =
|
|
"活检过程中没有检测到人脸!活体检测失败!";
|
|
"活检过程中没有检测到人脸!活体检测失败!";
|
|
@@ -738,7 +748,10 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const detectEndTime = performance.now();
|
|
const detectEndTime = performance.now();
|
|
- console.log("single detect time: ", detectEndTime - detectStartTime);
|
|
|
|
|
|
+ console.log(
|
|
|
|
+ "live single detect time: ",
|
|
|
|
+ detectEndTime - detectStartTime
|
|
|
|
+ );
|
|
if (this.shouldDetectExpression && this.behavingStartDate) {
|
|
if (this.shouldDetectExpression && this.behavingStartDate) {
|
|
// 到指定区块后才开始检测表情
|
|
// 到指定区块后才开始检测表情
|
|
if (result.expressions.happy < 0.5 && this.currentStep.happy) {
|
|
if (result.expressions.happy < 0.5 && this.currentStep.happy) {
|
|
@@ -774,7 +787,7 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (this.happyFailedTimes >= 6) {
|
|
|
|
|
|
+ if (this.happyFailedTimes / this.totalDetectTimes >= 0.4) {
|
|
this.corFinalResult.result = false;
|
|
this.corFinalResult.result = false;
|
|
this.corFinalResult.errorMsg = "指定表情失败!活体检测失败!";
|
|
this.corFinalResult.errorMsg = "指定表情失败!活体检测失败!";
|
|
this.failedTest("指定表情失败!活体检测失败!");
|
|
this.failedTest("指定表情失败!活体检测失败!");
|