|
@@ -56,6 +56,7 @@ const fetchResource = genCache(
|
|
|
cadInfo,
|
|
cadInfo,
|
|
|
cad,
|
|
cad,
|
|
|
traces,
|
|
traces,
|
|
|
|
|
+ detects,
|
|
|
] = await Promise.all([
|
|
] = await Promise.all([
|
|
|
get("/user/floorplan.json", {}),
|
|
get("/user/floorplan.json", {}),
|
|
|
get("/data/floorplan.json", { floors: [] }),
|
|
get("/data/floorplan.json", { floors: [] }),
|
|
@@ -65,6 +66,7 @@ const fetchResource = genCache(
|
|
|
get("/data/floorplan/info.json", { floors: [] }),
|
|
get("/data/floorplan/info.json", { floors: [] }),
|
|
|
get("/data/floorplan_cad.json", { floors: [] }),
|
|
get("/data/floorplan_cad.json", { floors: [] }),
|
|
|
get("/user/evidence.json", []),
|
|
get("/user/evidence.json", []),
|
|
|
|
|
+ get("/images/ai/detect/detect-ai.json", []),
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
@@ -77,6 +79,7 @@ const fetchResource = genCache(
|
|
|
cadInfo,
|
|
cadInfo,
|
|
|
config,
|
|
config,
|
|
|
traces,
|
|
traces,
|
|
|
|
|
+ detects,
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
150000
|
|
150000
|
|
@@ -116,7 +119,6 @@ export const getCoverLine = async (
|
|
|
...floorInfo?.bound,
|
|
...floorInfo?.bound,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- console.log(floor.cadInfo.cadBoundingBox, floorInfo?.bound);
|
|
|
|
|
if (!bound || !("x_max" in bound)) {
|
|
if (!bound || !("x_max" in bound)) {
|
|
|
const xs = geos.flatMap((item) => item.map((p) => p.x));
|
|
const xs = geos.flatMap((item) => item.map((p) => p.x));
|
|
|
const ys = geos.flatMap((item) => item.map((p) => p.y));
|
|
const ys = geos.flatMap((item) => item.map((p) => p.y));
|
|
@@ -251,7 +253,6 @@ export const getTraceTaggingInfos = async (
|
|
|
const infos: TaggingInfo[] = [];
|
|
const infos: TaggingInfo[] = [];
|
|
|
const reqs: Promise<any>[] = [];
|
|
const reqs: Promise<any>[] = [];
|
|
|
|
|
|
|
|
- console.log("traces", traces);
|
|
|
|
|
for (const trace of traces) {
|
|
for (const trace of traces) {
|
|
|
if (
|
|
if (
|
|
|
!validNum(trace.position?.x) ||
|
|
!validNum(trace.position?.x) ||
|
|
@@ -477,9 +478,10 @@ export const getAITaggingInfos = async (
|
|
|
export const getAIBorderTaggingInfos = async (
|
|
export const getAIBorderTaggingInfos = async (
|
|
|
scene: Scene,
|
|
scene: Scene,
|
|
|
subgroup: any,
|
|
subgroup: any,
|
|
|
- bound: Record<string, number>
|
|
|
|
|
|
|
+ bound: Record<string, number>,
|
|
|
|
|
+ scale: number
|
|
|
) => {
|
|
) => {
|
|
|
- const { ais } = await fetchResource(scene);
|
|
|
|
|
|
|
+ const { detects } = await fetchResource(scene);
|
|
|
const infos: BorderTaggingInfo[] = [];
|
|
const infos: BorderTaggingInfo[] = [];
|
|
|
const drawBound = {
|
|
const drawBound = {
|
|
|
x: bound.x_min,
|
|
x: bound.x_min,
|
|
@@ -487,53 +489,46 @@ export const getAIBorderTaggingInfos = async (
|
|
|
w: bound.x_max - bound.x_min,
|
|
w: bound.x_max - bound.x_min,
|
|
|
h: bound.y_max - bound.y_min,
|
|
h: bound.y_max - bound.y_min,
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
- for (const data of ais) {
|
|
|
|
|
- if (data.imagePath) {
|
|
|
|
|
- const reg = data.imagePath.match(/floor_(\d)\.png/);
|
|
|
|
|
- const curSubgroup = reg ? Number(reg[1]) : undefined;
|
|
|
|
|
- if (curSubgroup !== subgroup) continue;
|
|
|
|
|
|
|
+ // 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;
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ const min = { x: shape.bbox[0][0], y: shape.bbox[0][2] };
|
|
|
|
|
+ const max = { x: shape.bbox[0][0], y: shape.bbox[0][2] };
|
|
|
|
|
+ for (const box of shape.bbox) {
|
|
|
|
|
+ min.x = Math.min(box[0], min.x);
|
|
|
|
|
+ min.y = Math.min(box[2], min.y);
|
|
|
|
|
+ max.x = Math.max(box[0], max.x);
|
|
|
|
|
+ max.y = Math.max(box[2], 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,
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- for (const shape of data.shapes) {
|
|
|
|
|
- const icon =
|
|
|
|
|
- shape.category in aiIconMap
|
|
|
|
|
- ? (aiIconMap as any)[shape.category]
|
|
|
|
|
- : shape.category;
|
|
|
|
|
- const itemIcon = getIconItem(icon);
|
|
|
|
|
- const isWall = itemIcon && "wall" in itemIcon ? itemIcon.wall : false;
|
|
|
|
|
- if (isWall) continue;
|
|
|
|
|
-
|
|
|
|
|
- const name = itemIcon?.name || "";
|
|
|
|
|
- const isTag = icon === "Tag";
|
|
|
|
|
- if (!name || isTag) continue;
|
|
|
|
|
-
|
|
|
|
|
- const pixelCenter = {
|
|
|
|
|
- x: (shape.bbox[0] + shape.bbox[2]) / 2 / data.imageWidth,
|
|
|
|
|
- y: (shape.bbox[1] + shape.bbox[3]) / 2 / data.imageHeight,
|
|
|
|
|
- };
|
|
|
|
|
- const center = {
|
|
|
|
|
- x: pixelCenter.x * drawBound.w + drawBound.x,
|
|
|
|
|
- y: pixelCenter.y * drawBound.h + drawBound.y,
|
|
|
|
|
- };
|
|
|
|
|
- const size = {
|
|
|
|
|
- width:
|
|
|
|
|
- ((shape.bbox[2] - shape.bbox[0]) / data.imageWidth) * drawBound.w,
|
|
|
|
|
- height:
|
|
|
|
|
- ((shape.bbox[3] - shape.bbox[1]) / data.imageHeight) * drawBound.h,
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- infos.push({
|
|
|
|
|
- text: 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,
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ 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;
|
|
return infos;
|
|
|
};
|
|
};
|
|
@@ -547,7 +542,6 @@ export const getWallAITaggingInfos = async (
|
|
|
const { floorplan } = await fetchResource(scene);
|
|
const { floorplan } = await fetchResource(scene);
|
|
|
const infos: WallTaggingInfo[] = [];
|
|
const infos: WallTaggingInfo[] = [];
|
|
|
|
|
|
|
|
- console.log(cover.geos);
|
|
|
|
|
const getCoverLine = (wall: Pos[]) => {
|
|
const getCoverLine = (wall: Pos[]) => {
|
|
|
type Info = { p: Pos & { key: string }; len: number };
|
|
type Info = { p: Pos & { key: string }; len: number };
|
|
|
const infos: { start: Info; end: Info; inv: boolean }[] = [];
|
|
const infos: { start: Info; end: Info; inv: boolean }[] = [];
|
|
@@ -663,7 +657,7 @@ export const getResource = async ({
|
|
|
getAITaggingInfos(scene, key, cover.bound).then((ts) =>
|
|
getAITaggingInfos(scene, key, cover.bound).then((ts) =>
|
|
|
taggings.push(...ts)
|
|
taggings.push(...ts)
|
|
|
),
|
|
),
|
|
|
- getAIBorderTaggingInfos(scene, key, cover.bound).then((ts) =>
|
|
|
|
|
|
|
+ getAIBorderTaggingInfos(scene, key, cover.bound, scale).then((ts) =>
|
|
|
borderTaggings.push(...ts)
|
|
borderTaggings.push(...ts)
|
|
|
),
|
|
),
|
|
|
])
|
|
])
|
|
@@ -680,7 +674,6 @@ export const getResource = async ({
|
|
|
getBillTaggingInfos(scene, scale, key).then((ts) => taggings.push(...ts))
|
|
getBillTaggingInfos(scene, scale, key).then((ts) => taggings.push(...ts))
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
- console.error(syncs);
|
|
|
|
|
if (syncs.includes("traces")) {
|
|
if (syncs.includes("traces")) {
|
|
|
reqs.push(
|
|
reqs.push(
|
|
|
getTraceTaggingInfos(scene, scale, floorIndex).then((ts) =>
|
|
getTraceTaggingInfos(scene, scale, floorIndex).then((ts) =>
|