Skip to content
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

Avoid crashing when the x or y offset is too large #423

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions image_proc/src/nodelets/crop_decimate.cpp
Expand Up @@ -195,8 +195,24 @@ void CropDecimateNodelet::imageCb(const sensor_msgs::ImageConstPtr& image_msg,
config.height &= ~0x1;
}

// TODO(lucasw) need to incorporate the x_offset and y_offset within info_msg

// TODO(lucasw) should generate a black image where there isn't any source image,
// could be a dynamic reconfigure option
JWhitleyWork marked this conversation as resolved.
Show resolved Hide resolved
int max_width = image_msg->width - config.x_offset;
if (max_width <= 0)
{
ROS_DEBUG_STREAM("x offset is outside the input image width: "
JWhitleyWork marked this conversation as resolved.
Show resolved Hide resolved
<< image_msg->width << ", x offset: " << config.x_offset);
return;
}
int max_height = image_msg->height - config.y_offset;
if (max_height <= 0)
{
ROS_DEBUG_STREAM("y offset is outside the input image height: "
<< image_msg->height << ", y offset: " << config.y_offset);
return;
}
int width = config.width;
int height = config.height;
if (width == 0 || width > max_width)
Expand Down