|
@@ -5,6 +5,7 @@
|
|
|
<script>
|
|
|
import * as faceapi from "face-api.js";
|
|
|
import { FACE_API_MODEL_PATH } from "@/constants/constants";
|
|
|
+import { mapGetters as globalMapGetters } from "vuex";
|
|
|
|
|
|
window.faceapi = faceapi;
|
|
|
|
|
@@ -75,6 +76,9 @@ function getFaceDetectorOptions() {
|
|
|
const detectTimeArray = [];
|
|
|
export default {
|
|
|
name: "FaceTracking",
|
|
|
+ computed: {
|
|
|
+ ...globalMapGetters(["isEpcc"]),
|
|
|
+ },
|
|
|
async created() {
|
|
|
await faceapi.nets.tinyFaceDetector.load(FACE_API_MODEL_PATH);
|
|
|
// faceapi.nets.faceRecognitionNet.load(modelsPath);
|
|
@@ -99,13 +103,16 @@ export default {
|
|
|
console.log("start tracking ... ");
|
|
|
await that.detectFaces();
|
|
|
}
|
|
|
- this.trackHeadInterval = setInterval(() => {
|
|
|
- if (trackStarted) {
|
|
|
- clearInterval(this.trackHeadInterval);
|
|
|
- } else {
|
|
|
- trackHead();
|
|
|
- }
|
|
|
- }, 1000);
|
|
|
+ if (!this.isEpcc) {
|
|
|
+ // EPCC 关闭人脸实时检测
|
|
|
+ this.trackHeadInterval = setInterval(() => {
|
|
|
+ if (trackStarted) {
|
|
|
+ clearInterval(this.trackHeadInterval);
|
|
|
+ } else {
|
|
|
+ trackHead();
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
clearInterval(this.trackHeadInterval);
|
|
@@ -118,7 +125,7 @@ export default {
|
|
|
this.multipleTimeUsage = this.multipleTimeUsage || 0;
|
|
|
if (
|
|
|
this.singleTimeUsage > 10 * 1000 ||
|
|
|
- this.multipleTimeUsage > 3 * 1000
|
|
|
+ this.multipleTimeUsage > 0.5 * 1000
|
|
|
) {
|
|
|
window._hmt.push([
|
|
|
"_trackEvent",
|
|
@@ -161,11 +168,11 @@ export default {
|
|
|
);
|
|
|
this.singleTimeUsage = detectEndTime - detectStartTime;
|
|
|
|
|
|
- if (detectTimeArray.length < 11) {
|
|
|
+ if (detectTimeArray.length < 6) {
|
|
|
// 仅捕获一部分检测次数
|
|
|
detectTimeArray.push(detectEndTime - detectStartTime);
|
|
|
}
|
|
|
- if (detectTimeArray.length === 11) {
|
|
|
+ if (detectTimeArray.length === 6) {
|
|
|
detectTimeArray.shift();
|
|
|
const avg =
|
|
|
detectTimeArray.reduce((a, b) => a + b, 0) / detectTimeArray.length;
|