One log line per phase every PHASE_LOG_EVERY samples (default 100, 0 = off): mean and max of wait_frames, align, convert, each JPEG/PNG encoding, colormap, depth_stats, base64, json and ws_send. Meant for the measurement on PC2 via `docker logs` (optimize-streams R01): where a capture spends its ~130 ms of CPU is not known yet. capture() moves its numpy conversion into _frame_from() unchanged, only so the block can be timed; _depth_colormap() likewise wraps _jet_colormap(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# Server
|
|
api_host: str = "0.0.0.0"
|
|
api_port: int = 8878
|
|
|
|
# NATS
|
|
nats_url: str = "nats://nats:4222"
|
|
nats_token: str = ""
|
|
|
|
# Service identity
|
|
service_name: str = "realsense-d435"
|
|
service_domain: str = "vision"
|
|
|
|
# Security
|
|
api_key: str = ""
|
|
|
|
# Storage
|
|
images_dir: str = "/app/images"
|
|
|
|
# RealSense stream config
|
|
camera_width: int = 640
|
|
camera_height: int = 480
|
|
camera_fps: int = 30
|
|
camera_auto_open: bool = True
|
|
|
|
# Frame-path timings: one log line per phase every N samples (0 = off).
|
|
# Read from `docker logs` to see where a capture spends its time on PC2.
|
|
phase_log_every: int = 100
|
|
|
|
# YOLO detector (optional — disabled if model file or onnxruntime missing)
|
|
yolo_onnx_path: str = "/app/models/best.onnx"
|
|
yolo_classes: str = ""
|
|
yolo_conf_default: float = 0.5
|
|
|
|
@property
|
|
def yolo_class_list(self) -> list[str]:
|
|
return [s.strip() for s in self.yolo_classes.split(",") if s.strip()]
|
|
|
|
# CORS (comma-separated string, parsed into list)
|
|
cors_origins: str = "http://localhost:5173,http://localhost,http://localhost:80"
|
|
|
|
@property
|
|
def cors_origins_list(self) -> list[str]:
|
|
return [s.strip() for s in self.cors_origins.split(",")]
|
|
|
|
model_config = {
|
|
"env_file": ".env",
|
|
"env_file_encoding": "utf-8",
|
|
}
|
|
|
|
|
|
settings = Settings()
|