-
Notifications
You must be signed in to change notification settings - Fork 14
Drop queued frames in live display #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When in live mode, drain any queued frames from show_img_pipe so only the most recent image is processed, preventing visible display lag from a pipe backlog. Count dropped frames, log a debug message when frames are dropped, and include dropped frames in images_received. Preserve existing handling for the "stop" sentinel and non-int image ids.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1173 +/- ##
========================================
Coverage 52.51% 52.52%
========================================
Files 197 197
Lines 23976 23985 +9
========================================
+ Hits 12592 12597 +5
- Misses 11384 11388 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds frame dropping logic to prevent display lag during live image acquisition. When the image processing pipeline cannot keep up with the frame rate, queued frames accumulate in the pipe, causing visible lag. The PR addresses this by draining old frames and displaying only the most recent frame when in live mode.
Changes:
- Added frame draining logic in live mode that skips queued frames to process only the most recent one
- Added counter and debug logging for dropped frames
- Updated images_received to include dropped frames in the total count
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| image=self.data_buffer[image_id] | ||
| ) | ||
| images_received += 1 | ||
| images_received += 1 + dropped_frames |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including dropped_frames in images_received may be semantically incorrect. The variable name suggests it counts images that were actually received and processed, but dropped frames are explicitly NOT processed (they're skipped to reduce lag). This could lead to confusion or incorrect reporting of how many images were actually displayed. Consider whether images_received should only count processed images, and track dropped frames separately if needed for reporting purposes.
| images_received += 1 + dropped_frames | |
| images_received += 1 |
| if mode == "live": | ||
| # Drain queued frames so we only process the most recent one. | ||
| # This prevents the pipe backlog from causing visible display lag. | ||
| while self.show_img_pipe.poll(): | ||
| image_id = self.show_img_pipe.recv() | ||
| dropped_frames += 1 | ||
| if image_id == "stop" or not isinstance(image_id, int): | ||
| break |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new frame dropping logic in live mode is not covered by the existing test_capture_image test, which mocks poll() to always return False. Consider adding test cases that verify the frame dropping behavior when multiple frames are queued, including edge cases like receiving "stop" or non-int image_ids while draining.
|
@annie-xd-wang - We now include another safeguard which should prevent a laggy display. @conorhughmcfadden has tested it, and it appears to be functional. Camera display no longer lags significantly. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
When in live mode, drain any queued frames from show_img_pipe so only the most recent image is processed, preventing visible display lag from a pipe backlog. Count dropped frames, log a debug message when frames are dropped, and include dropped frames in images_received. Preserve existing handling for the "stop" sentinel and non-int image ids.