feat(tracker): print startup + periodic status lines (no GUI on this path)
The Linux Python tracker is headless by design - no window, no camera picker, no live preview; those only exist in the Windows-only tracker-native/ GUI, which cannot run under Wine (docs/linux-wine.md). But it also produced zero console output during a normal run, so a working tracker and a silently stuck one looked identical - which is what prompted "i don't see the window or picker or preview". Added: - a startup banner (camera source opening/opened, model loading, shm target + resolution + fps) so a terminal run shows the pipeline actually came up, - a periodic "[tracker] frame=N fps=F player=tracked|lost seq=S" status line (every 2s by default, Tracker.run(status_interval=...), disableable for tests) so a long-running session shows live confirmation it is still publishing frames and whether a person is currently detected. Verified for real: ran the CLI against both a synthetic test video (confirms the startup banner, mediapipe loads and infers) and a paced fake source spanning several seconds (confirms the periodic status line fires on schedule with the right frame/fps/player fields). Full tests/test_tracker.py suite still passes (10/10, 0.78s) - the fast unit-test runs finish well under the 2s default interval, so no new output or timing coupling there. Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
1 parent
c4796d7dcf
commit
1cc8dc3515
1 file changed
+34
-1
+34
-1
@@ -154,13 +154,24 @@ class Tracker:
|
||||
self._hold_remaining -= 1
|
||||
return pose, frame
|
||||
|
||||
def run(self, max_frames: Optional[int] = None, max_seconds: Optional[float] = None) -> int:
|
||||
def run(
|
||||
self,
|
||||
max_frames: Optional[int] = None,
|
||||
max_seconds: Optional[float] = None,
|
||||
status_interval: Optional[float] = 2.0,
|
||||
) -> int:
|
||||
# The tracker has no GUI (that only exists in the Windows-only
|
||||
# tracker-native/) and otherwise produces zero output, so a working run
|
||||
# looks identical to a silently stuck one. Print a status line every
|
||||
# status_interval seconds (None disables it, e.g. for tests) so a
|
||||
# terminal run shows live confirmation instead of nothing.
|
||||
self._worker = threading.Thread(target=self._inference_worker, name="inference", daemon=True)
|
||||
self._worker.start()
|
||||
|
||||
period = 1.0 / self.target_fps
|
||||
start = time.monotonic()
|
||||
published = 0
|
||||
last_status = start
|
||||
while not self._stop.is_set():
|
||||
deadline = start + published * period
|
||||
now = time.monotonic()
|
||||
@@ -174,6 +185,17 @@ class Tracker:
|
||||
self.control.send_heartbeat(seq)
|
||||
published += 1
|
||||
|
||||
now = time.monotonic()
|
||||
if status_interval is not None and now - last_status >= status_interval:
|
||||
elapsed = now - start
|
||||
fps = published / elapsed if elapsed > 0 else 0.0
|
||||
print(
|
||||
f"[tracker] frame={published} fps={fps:.1f} "
|
||||
f"player={'tracked' if pose is not None else 'lost'} seq={seq}",
|
||||
flush=True,
|
||||
)
|
||||
last_status = now
|
||||
|
||||
if max_frames is not None and published >= max_frames:
|
||||
break
|
||||
if max_seconds is not None and (time.monotonic() - start) >= max_seconds:
|
||||
@@ -237,11 +259,22 @@ def main(argv: Optional[list[str]] = None) -> int:
|
||||
print(f"{tier}: {fps:.1f} fps")
|
||||
return 0
|
||||
|
||||
# No GUI on this path (camera picker / live preview only exist in the
|
||||
# Windows-only tracker-native/); print confirmation so a terminal run
|
||||
# shows the camera actually opened instead of silently doing nothing.
|
||||
print(f"[tracker] opening camera source={args.source!r} ...", flush=True)
|
||||
source = CvFrameSource(args.source)
|
||||
print(f"[tracker] camera opened; loading pose model (tier/path={args.model!r}) ...", flush=True)
|
||||
provider = MediaPipePoseProvider(model=args.model, models_dir=args.models_dir)
|
||||
publisher = FrameContractPublisher(
|
||||
depth_size=args.depth_size, color_size=args.color_size, name=args.shm_name
|
||||
)
|
||||
print(
|
||||
f"[tracker] publishing to shared memory '{args.shm_name}' "
|
||||
f"({args.depth_size[0]}x{args.depth_size[1]} depth, "
|
||||
f"{args.color_size[0]}x{args.color_size[1]} color) at {args.target_fps} fps target",
|
||||
flush=True,
|
||||
)
|
||||
control = None
|
||||
if args.control_socket:
|
||||
control = ControlPlaneServer(args.control_socket)
|
||||
|
||||
Reference in new issue
Block a user