mirror of
https://github.com/SikongJueluo/Mini-Nav.git
synced 2026-07-12 20:15:31 +08:00
feat(scenegraph): add SceneGraphBuilder for pipeline-driven graph construction
Introduce SceneGraphBuilder + SceneGraphBuildConfig to decouple scene graph construction from the verification notebook. The builder handles batch inference, hash encoding, and object node creation internally. - Add SceneGraphBuilder.build_from_room_views() as the main entry point - Add SceneGraphBuildConfig for inference_batch_size and position strategy - Add SceneGraphBuildArtifacts to carry cropped images and debug metadata - Extend ObjectNode with optional detection metadata (label, confidence, bbox_xyxy, source_view_id, position_confidence) - Add RoomView frozen dataclass as a structured view container - Add flatten_room_views() utility to replace inline list comprehensions - Refactor notebooks/verification.py to use the new builder API BREAKING CHANGE: ObjectNode now accepts additional optional fields; direct scene_graph.objects[obj_id] = ObjectNode(...) construction in the notebook is replaced by builder.build_from_room_views(...).
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
import numpy as np
|
||||
@@ -20,10 +22,20 @@ class ObjectNode:
|
||||
hit_count: int = 1 # 被观测到的次数。太低的可以直接过滤掉
|
||||
last_seen_frame: int = 0 # 最后一次看到的帧号或时间戳
|
||||
|
||||
# Optional detection metadata (from M0 integration)
|
||||
label: str | None = None
|
||||
confidence: float | None = None
|
||||
bbox_xyxy: tuple[float, float, float, float] | None = None
|
||||
source_view_id: str | None = None
|
||||
position_confidence: float | None = None
|
||||
|
||||
def __post_init__(self):
|
||||
self.position = np.asarray(self.position, dtype=np.float32)
|
||||
if len(self.visual_hash) != 64:
|
||||
raise ValueError("visual_hash must be exactly 64 bytes (512 bits)")
|
||||
if len(self.semantic_hash) != 64:
|
||||
raise ValueError("semantic_hash must be exactly 64 bytes (512 bits)")
|
||||
if self.position.shape != (3,):
|
||||
raise ValueError("position must have shape (3,)")
|
||||
if self.bbox_xyxy is not None and len(self.bbox_xyxy) != 4:
|
||||
raise ValueError("bbox_xyxy must have exactly 4 elements")
|
||||
|
||||
Reference in New Issue
Block a user