Parse config.yaml into typed AppConfig dataclass
- ServerConfig, VideoConfig, ModelConfig, DeadBugConfig, AudioConfig, LoggingConfig as nested dataclasses - Consumers use config.server.host, config.model.resolved_path etc. - env var overrides preserved via _apply_env_overrides()
This commit is contained in:
@@ -10,17 +10,7 @@ from loguru import logger
|
||||
from app.audio.rep_announcer import RepAnnouncer
|
||||
from app.exercises.dead_bug.detector import DeadBugDetector
|
||||
from app.rendering.window_display import close_window, is_esc_pressed, show_frame
|
||||
from configs.load import (
|
||||
EXTENSION_CONFIRM_FRAMES,
|
||||
MODEL_PATH,
|
||||
PREFER_GPU,
|
||||
PROCESS_EVERY_N_FRAMES,
|
||||
REP_ANNOUNCER_ENABLED,
|
||||
REP_ANNOUNCER_RATE,
|
||||
REP_ANNOUNCER_VOLUME,
|
||||
RESET_CONFIRM_FRAMES,
|
||||
VISIBILITY_THRESHOLD,
|
||||
)
|
||||
from configs.load import config
|
||||
|
||||
|
||||
def _format_pose_debug(pose_result) -> str:
|
||||
@@ -41,21 +31,21 @@ class VideoReceiver:
|
||||
self._track = track
|
||||
|
||||
async def run(self) -> None:
|
||||
logger.info("Start receiving video frames, process_every_n={}", PROCESS_EVERY_N_FRAMES)
|
||||
logger.info("Start receiving video frames, process_every_n={}", config.video.process_every_n_frames)
|
||||
|
||||
frame_count = 0
|
||||
processed_count = 0
|
||||
detector = DeadBugDetector(
|
||||
model_path=MODEL_PATH,
|
||||
visibility_threshold=VISIBILITY_THRESHOLD,
|
||||
extension_confirm_frames=EXTENSION_CONFIRM_FRAMES,
|
||||
reset_confirm_frames=RESET_CONFIRM_FRAMES,
|
||||
prefer_gpu=PREFER_GPU,
|
||||
model_path=config.model.resolved_path,
|
||||
visibility_threshold=config.dead_bug.visibility_threshold,
|
||||
extension_confirm_frames=config.dead_bug.extension_confirm_frames,
|
||||
reset_confirm_frames=config.dead_bug.reset_confirm_frames,
|
||||
prefer_gpu=config.model.prefer_gpu,
|
||||
)
|
||||
announcer = RepAnnouncer(
|
||||
enabled=REP_ANNOUNCER_ENABLED,
|
||||
rate=REP_ANNOUNCER_RATE,
|
||||
volume=REP_ANNOUNCER_VOLUME,
|
||||
enabled=config.audio.rep_announcer_enabled,
|
||||
rate=config.audio.rep_announcer_rate,
|
||||
volume=config.audio.rep_announcer_volume,
|
||||
)
|
||||
last_announced_rep = 0
|
||||
last_pose_result = None
|
||||
@@ -68,7 +58,7 @@ class VideoReceiver:
|
||||
raw_img = frame.to_ndarray(format="bgr24")
|
||||
timestamp_ms = int(frame.time * 1000) if frame.time is not None else frame_count * 33
|
||||
|
||||
if frame_count % PROCESS_EVERY_N_FRAMES == 0 or last_pose_result is None:
|
||||
if frame_count % config.video.process_every_n_frames == 0 or last_pose_result is None:
|
||||
processed_count += 1
|
||||
last_annotated, last_pose_result = detector.process_frame(raw_img, timestamp_ms)
|
||||
if last_pose_result.rep_count > last_announced_rep:
|
||||
|
||||
Reference in New Issue
Block a user