fix: validate camera frame before processing in VLM input plugins #2208
+82
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
cap.read()returns(ret, frame)butretwas never checked in three VLM input plugins. When the camera drops a frame (ret=False, frame=None), theNoneframe gets passed to model inference and crashes the runtime.vlm_local_yolo.py,vlm_coco_local.py, andwebcam_to_face_emotion.py. The correct pattern already exists inunitree_realsense_dev_vlm_provider.py— this PR brings the other plugins in line.cam_thirdwith a safe default invlm_local_yoloso_raw_to_textdoesn't raiseAttributeErrorwhen 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
test_poll_returns_none_on_failed_frame_readfor YOLO plugintest_poll_returns_none_on_none_framefor YOLO plugin (ret=True but frame=None edge case)test_cam_third_initialized_without_camerafor safe default initializationtest_poll_returns_none_on_failed_frame_readfor COCO plugin