"""Centralized configuration for the navigation system.""" import os # Model paths YOLO_MODEL = os.environ.get("NAV_YOLO_MODEL", "yolov8n.pt") POSE_MODEL = os.environ.get("NAV_POSE_MODEL", os.path.join(os.path.dirname(__file__), "pose_landmarker_heavy.task")) # Depth model options: "small", "base", "v2-small", "v2-base" # v2 models are more accurate. "small" variants are faster. DEPTH_MODEL = os.environ.get("NAV_DEPTH_MODEL", "small") DEPTH_INPUT_SIZE = int(os.environ.get("NAV_DEPTH_INPUT_SIZE", 384)) # resize before inference DEVICE = os.environ.get("NAV_DEVICE", "cpu") # Auto-detect GPU if not explicitly set if "NAV_DEVICE" not in os.environ: try: import torch if torch.cuda.is_available(): DEVICE = "cuda" except ImportError: pass # Detection YOLO_CONF = 0.25 OBSTACLE_CLASSES = { 0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 5: 'bus', 7: 'truck', 9: 'traffic light', 10: 'fire hydrant', 11: 'stop sign', 13: 'bench', 15: 'cat', 16: 'dog', 24: 'backpack', 25: 'umbrella', 28: 'suitcase', 39: 'bottle', 56: 'chair', 57: 'sofa', 58: 'potted plant', 59: 'bed', 60: 'table', 62: 'tv', 63: 'laptop', 66: 'keyboard', 72: 'refrigerator', 73: 'book', } # Depth / slope GROUND_RATIO = 0.55 # default ground region starts at 55% of frame height SLOPE_MULTIPLIER = 20.0 # arctan scaling — calibrate on known slopes SLOPE_CLAMP = 35.0 # max slope angle (degrees) SLOPE_DEADZONE = 3.0 # angles below this → FLAT SLOPE_SMOOTHING = 0.7 # EMA alpha for temporal smoothing (0=no smoothing, 1=full cache) # Terrain roughness thresholds (std of ground depth) TERRAIN_ROCKY_THRESH = 0.25 TERRAIN_ROUGH_THRESH = 0.15 # Pose landmark indices LM = { 'L_SHOULDER': 11, 'R_SHOULDER': 12, 'L_HIP': 23, 'R_HIP': 24, 'L_KNEE': 25, 'R_KNEE': 26, 'L_ANKLE': 27, 'R_ANKLE': 28, 'L_HEEL': 29, 'R_HEEL': 30, 'L_FOOT': 31, 'R_FOOT': 32, } SKELETON_CONNS = [ (11, 13), (13, 15), (12, 14), (14, 16), (11, 12), (11, 23), (12, 24), (23, 24), (23, 25), (25, 27), (27, 29), (27, 31), (29, 31), (24, 26), (26, 28), (28, 30), (28, 32), (30, 32), ] # Risk thresholds RISK_HIGH = 60 RISK_MEDIUM = 30 RISK_LOW = 10 # User mobility profiles: "default", "elderly", "athletic" RISK_PROFILE = os.environ.get("NAV_RISK_PROFILE", "default") # Voice throttle VOICE_COOLDOWN_SEC = 2.5 # min seconds between repeated messages VOICE_SLOPE_DELTA = 5.0 # slope must change by this much to re-announce # Video processing DEFAULT_SKIP_FRAMES = 2 DEFAULT_DEPTH_EVERY = 5