Skip to content

feat: add FPS throttle to reduce CPU/energy usage - #10

Merged
johnoct merged 1 commit into
mainfrom
feat/fps-throttle
Feb 6, 2026
Merged

feat: add FPS throttle to reduce CPU/energy usage#10
johnoct merged 1 commit into
mainfrom
feat/fps-throttle

Conversation

@johnoct

@johnoct johnoct commented Feb 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add --fps CLI flag (default 10, 0 = unlimited) to cap the detection loop frame rate
  • Add throttle_fps() helper that sleeps the remaining frame budget each iteration
  • Fix double apply_night_mode call on motion frames — CLAHE now only runs once for snapshots

Test plan

  • New tests for --fps argument defaults and custom values
  • New tests for throttle_fps(): sleep behavior, no-sleep when over budget, fps=0 bypass
  • All 52 existing tests pass with no regressions
  • Manual: run babyping and verify CPU usage is significantly lower than before
  • Manual: run with --fps 5 and --fps 0 to verify tunability

The detection loop was running uncapped, consuming maximum CPU. Add a
--fps flag (default 10) with a throttle_fps() helper that sleeps the
remaining frame budget each iteration. Also fix double apply_night_mode
on motion frames — snapshots now only apply CLAHE when --snapshots is
enabled instead of unconditionally.
@johnoct
johnoct merged commit 1d7e76c into main Feb 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant