Add input validation and error handling in depth processing methods#106
Merged
mgonzs13 merged 1 commit intomgonzs13:mainfrom Jan 19, 2026
Merged
Conversation
- Add input validation for depth images and arrays (None, empty, non-ndarray) - Check for NaN, infinity, and zero values before processing - Validate camera intrinsic parameters (fx, fy) to prevent division by zero - Convert numpy float types to Python floats for ROS message compatibility - Add early returns with safe default values (0.0, 0.0, 0.0) on validation failures - Validate intermediate calculation results to prevent propagation of invalid values This prevents crashes when dealing with: - Invalid depth camera data (NaN, inf values) - Empty depth regions or arrays - Invalid camera calibration data - Division by zero scenarios - Edge cases during depth sensor failures Affected methods: - compute_depth_bounds() - convert_bb_to_3d() - _compute_height_bounds() - _compute_width_bounds() - _compute_depth_bounds_weighted() - convert_keypoints_to_3d() Tested with edge cases including corrupted depth data, NaN/inf values, zero divisions, and empty arrays. All validations return safe defaults.
e88bbaf to
547065d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR adds comprehensive input validation and float handling to prevent crashes when processing depth images with unusual or invalid values.
Changes Made
depth_imageinputs (None, empty, non-ndarray)(0.0, 0.0, 0.0)when validation failsMotivation
The node was crashing when receiving:
Affected Methods
compute_depth_bounds()convert_bb_to_3d()_compute_height_bounds()_compute_width_bounds()_compute_depth_bounds_weighted()convert_keypoints_to_3d()