|
@@ -6,6 +6,8 @@
|
|
|
import * as faceapi from "face-api.js";
|
|
|
import { FACE_API_MODEL_PATH } from "@/constants/constants";
|
|
|
|
|
|
+window.faceapi = faceapi;
|
|
|
+
|
|
|
const os = (function() {
|
|
|
const ua = navigator.userAgent.toLowerCase();
|
|
|
return {
|
|
@@ -19,6 +21,24 @@ const os = (function() {
|
|
|
};
|
|
|
})();
|
|
|
|
|
|
+function webgl_available() {
|
|
|
+ var canvas = document.createElement("canvas");
|
|
|
+ var gl = canvas.getContext("webgl");
|
|
|
+
|
|
|
+ return gl && gl instanceof WebGLRenderingContext;
|
|
|
+}
|
|
|
+
|
|
|
+function getCPUModel() {
|
|
|
+ if (typeof nodeRequire != "undefined") {
|
|
|
+ var os = window.nodeRequire("os");
|
|
|
+ const cpus = os.cpus();
|
|
|
+ if (cpus.length > 0) {
|
|
|
+ return cpus[0].model;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "null";
|
|
|
+}
|
|
|
+
|
|
|
// if (os.isWin7) alert("是win7");
|
|
|
|
|
|
// if (os.isWin10) alert("是win10");
|
|
@@ -121,7 +141,7 @@ export default {
|
|
|
detectTimeArray.shift();
|
|
|
const avg =
|
|
|
detectTimeArray.reduce((a, b) => a + b, 0) / detectTimeArray.length;
|
|
|
- const roundAvg = Math.round(avg / 10) * 10;
|
|
|
+ const roundAvg = Math.round(avg / 100) * 100;
|
|
|
window._hmt.push([
|
|
|
"_trackEvent",
|
|
|
"正在考试页面",
|
|
@@ -130,6 +150,16 @@ export default {
|
|
|
]);
|
|
|
console.log(detectTimeArray);
|
|
|
detectTimeArray.push(0, 0); // 避免再次达到push条件和上传条件
|
|
|
+
|
|
|
+ const roundAvg100 = Math.round(avg / 100) * 100;
|
|
|
+ const osType = os.isWin7 ? "win7" : os.isWin10 ? "win10" : "other";
|
|
|
+ const stats = `webgl: ${webgl_available()}; tf_backend: ${faceapi.tf.getBackend()}; os: ${osType}; cpu: ${getCPUModel()}`;
|
|
|
+ window._hmt.push([
|
|
|
+ "_trackEvent",
|
|
|
+ "正在考试页面",
|
|
|
+ "实时人脸检测统计" + roundAvg100 + "ms",
|
|
|
+ stats,
|
|
|
+ ]);
|
|
|
}
|
|
|
if (result.length >= 2) {
|
|
|
this.$Message.warning({
|