Przeglądaj źródła

feat: 去除点云aiBorder

bill 1 dzień temu
rodzic
commit
1498bb9d9e
1 zmienionych plików z 74 dodań i 56 usunięć
  1. 74 56
      src/example/platform/resource-swkk.ts

+ 74 - 56
src/example/platform/resource-swkk.ts

@@ -56,7 +56,7 @@ const fetchResource = genCache(
       cadInfo,
       cad,
       traces,
-      detects,
+      // detects,
     ] = await Promise.all([
       get("/user/floorplan.json", {}),
       get("/data/floorplan.json", { floors: [] }),
@@ -66,7 +66,7 @@ const fetchResource = genCache(
       get("/data/floorplan/info.json", { floors: [] }),
       get("/data/floorplan_cad.json", { floors: [] }),
       get("/user/evidence.json", []),
-      get("/images/ai/detect/detect-ai.json", []),
+      // get("/images/ai/detect/detect-ai.json", []),
     ]);
 
     return {
@@ -79,7 +79,7 @@ const fetchResource = genCache(
       cadInfo,
       config,
       traces,
-      detects,
+      // detects,
     };
   },
   150000
@@ -416,7 +416,8 @@ export const getBillTaggingInfos = async (
 export const getAITaggingInfos = async (
   scene: Scene,
   subgroup: any,
-  bound: Record<string, number>
+  bound: Record<string, number>,
+  getTag = true
 ) => {
   const { ais } = await fetchResource(scene);
   const infos: TaggingInfo[] = [];
@@ -445,7 +446,8 @@ export const getAITaggingInfos = async (
 
       const name = itemIcon?.name || "";
       const isTag = icon === "Tag";
-      if (!name && !isTag) continue;
+      if (getTag && !isTag) continue;
+      if (!name) continue;
 
       const pixelCenter = {
         x: (shape.bbox[0] + shape.bbox[2]) / 2 / data.imageWidth,
@@ -481,59 +483,75 @@ export const getAIBorderTaggingInfos = async (
   bound: Record<string, number>,
   scale: number
 ) => {
-  const { detects } = await fetchResource(scene);
-  const infos: BorderTaggingInfo[] = [];
-  const drawBound = {
-    x: bound.x_min,
-    y: bound.y_min,
-    w: bound.x_max - bound.x_min,
-    h: bound.y_max - bound.y_min,
-  };
-  // console.log(drawBound);
-  for (const shape of detects) {
-    // if (data.imagePath) {
-    //   const reg = data.imagePath.match(/floor_(\d)\.png/);
-    //   const curSubgroup = reg ? Number(reg[1]) : undefined;
-    //   if (curSubgroup !== subgroup) continue;
-    // }
-    for (const box of shape.bbox) {
-      box[1] *= -1
-      // console.log(box)
-    }
-    const min = { x: shape.bbox[0][0], y: shape.bbox[0][1] };
-    const max = { x: shape.bbox[0][0], y: shape.bbox[0][1] };
-    for (const box of shape.bbox) {
-      min.x = Math.min(box[0], min.x);
-      min.y = Math.min(box[1], min.y);
-      max.x = Math.max(box[0], max.x);
-      max.y = Math.max(box[1], max.y);
-    }
-    min.x *= scale;
-    min.y *= scale;
-    max.x *= scale;
-    max.y *= scale;
-
-    const center = {
-      x: (min.x + max.x) / 2,
-      y: (min.y + max.y) / 2,
-    };
-    const size = {
-      width: max.x - min.x,
-      height: max.y - min.y,
-    };
-
-    infos.push({
-      text: shape.name,
+  const taggingInfos = await getAITaggingInfos(scene, subgroup, bound, false);
+  console.log(taggingInfos)
+  return taggingInfos.map((item) => {
+    const size = item.size!;
+    const p = item.position!;
+    return {
+      text: item.name || "",
       points: [
-        { x: center.x - size.width / 2, y: center.y - size.height / 2 },
-        { x: center.x + size.width / 2, y: center.y - size.height / 2 },
-        { x: center.x + size.width / 2, y: center.y + size.height / 2 },
-        { x: center.x - size.width / 2, y: center.y + size.height / 2 },
+        {
+          x: p.x - (size?.width || 0) / 2,
+          y: p.y - (size?.height || 0) / 2,
+        },
+        {
+          x: p.x + (size?.width || 0) / 2,
+          y: p.y - (size?.height || 0) / 2,
+        },
+        {
+          x: p.x + (size?.width || 0) / 2,
+          y: p.y + (size?.height || 0) / 2,
+        },
+        {
+          x: p.x - (size?.width || 0) / 2,
+          y: p.y + (size?.height || 0) / 2,
+        },
       ],
-      center,
-    });
-  }
-  return infos;
+      center: item.position!,
+    };
+  });
+
+  // const infos: BorderTaggingInfo[] = [];
+  // const { detects } = await fetchResource(scene);
+  // for (const shape of detects) {
+  //   for (const box of shape.bbox) {
+  //     box[1] *= -1
+  //   }
+  //   const min = { x: shape.bbox[0][0], y: shape.bbox[0][1] };
+  //   const max = { x: shape.bbox[0][0], y: shape.bbox[0][1] };
+  //   for (const box of shape.bbox) {
+  //     min.x = Math.min(box[0], min.x);
+  //     min.y = Math.min(box[1], min.y);
+  //     max.x = Math.max(box[0], max.x);
+  //     max.y = Math.max(box[1], max.y);
+  //   }
+  //   min.x *= scale;
+  //   min.y *= scale;
+  //   max.x *= scale;
+  //   max.y *= scale;
+
+  //   const center = {
+  //     x: (min.x + max.x) / 2,
+  //     y: (min.y + max.y) / 2,
+  //   };
+  //   const size = {
+  //     width: max.x - min.x,
+  //     height: max.y - min.y,
+  //   };
+
+  //   infos.push({
+  //     text: shape.name,
+  //     points: [
+  //       { x: center.x - size.width / 2, y: center.y - size.height / 2 },
+  //       { x: center.x + size.width / 2, y: center.y - size.height / 2 },
+  //       { x: center.x + size.width / 2, y: center.y + size.height / 2 },
+  //       { x: center.x - size.width / 2, y: center.y + size.height / 2 },
+  //     ],
+  //     center,
+  //   });
+  // }
+  // return infos;
 };
 
 export const getWallAITaggingInfos = async (