林旭祥 1 ヶ月 前
コミット
04ab301842
1 ファイル変更17 行追加4 行削除
  1. 17 4
      src/views/game/fruit.vue

+ 17 - 4
src/views/game/fruit.vue

@@ -23,9 +23,11 @@ const data = reactive<any>({
   againTimer: null,//定时状态
   wsState: false,//WS状态
   clientObj: {},//浏览器对象
+  boxes: [],//四个点坐标
+  proportion: null,//人框和屏幕比例
 });
 
-const { bodyposeData, bodyposeState, parameter, deviceInfo, againNum, againTimer, wsState, clientObj } = toRefs(data);
+const { bodyposeData, bodyposeState, parameter, deviceInfo, againNum, againTimer, wsState, clientObj, boxes, proportion } = toRefs(data);
 
 /**
  * 初始化
@@ -114,6 +116,13 @@ const getInit = async () => {
       }
       console.log("result", result)
       bodyposeData.value = result;
+      if (boxes.value.length == 0) {
+        speckText("识别成功");
+        proxy?.$modal.msgWarning(`识别成功`);
+        let arr = e.data.result.boxes;
+        boxes.value = [{ x: arr[0], y: arr[3] }, { x: arr[0], y: arr[1] }, { x: arr[2], y: arr[1] }, { x: arr[2], y: arr[3] }]
+        proportion.value = (clientObj.value.height / (arr[3] - arr[1])).toFixed(2);
+      }
       getCanvas(result);
     }
     if (e?.cmd == 'terminate_bodyposecontroller') {
@@ -156,9 +165,9 @@ const getCloseBodypose = () => {
 /**
  * 绘图
 */
-const getCanvas = (data) => {
-  console.log("data",data)
-  externalMethod(data[10][0],data[10][1])
+const getCanvas = (data:any) => {
+  console.log("data", data)
+  externalMethod(data[10][0], data[10][1])
 };
 
 
@@ -1560,6 +1569,10 @@ const getActiveScene = () => {
 };
 
 onBeforeMount(() => {
+  clientObj.value = {
+    width: document.documentElement.clientWidth,
+    height: document.documentElement.clientHeight,
+  }
   getInit();
 });