Skip to content

Conversation

@Ridwannurudeen
Copy link
Contributor

Summary

  • cap.read() returns (ret, frame) but ret was never checked in three VLM input plugins. When the camera drops a frame (ret=False, frame=None), the None frame gets passed to model inference and crashes the runtime.
  • This affects vlm_local_yolo.py, vlm_coco_local.py, and webcam_to_face_emotion.py. The correct pattern already exists in unitree_realsense_dev_vlm_provider.py — this PR brings the other plugins in line.
  • Also initializes cam_third with a safe default in vlm_local_yolo so _raw_to_text doesn't raise AttributeError when no camera is present.

This is especially relevant for simulation environments (Gazebo, Isaac Sim) where virtual camera devices may not have frames ready immediately at startup.

Closes #2207

Test plan

  • Added test_poll_returns_none_on_failed_frame_read for YOLO plugin
  • Added test_poll_returns_none_on_none_frame for YOLO plugin (ret=True but frame=None edge case)
  • Added test_cam_third_initialized_without_camera for safe default initialization
  • Added test_poll_returns_none_on_failed_frame_read for COCO plugin

cap.read() can return (False, None) when the camera drops a frame,
which happens during simulation startup with virtual camera devices
or when a physical camera temporarily loses connection. Three plugins
passed the unchecked frame directly to model inference, causing crashes.

- Add ret/frame validation in vlm_local_yolo, vlm_coco_local, and
  webcam_to_face_emotion to skip dropped frames gracefully
- Initialize cam_third with a safe default in vlm_local_yolo so
  _raw_to_text does not raise AttributeError when no camera is present
- Add tests for frame validation and safe initialization

Closes OpenMind#2207
@Ridwannurudeen Ridwannurudeen requested review from a team as code owners February 11, 2026 00:49
@github-actions github-actions bot added robotics Robotics code changes python Python code tests Test files labels Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: VLM input plugins crash on dropped camera frames (ret not checked)

1 participant