Skip to content

Commit

Permalink
Try catch around cvtColor to avoid demosaicing src.empty() error (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasw authored and Joshua Whitley committed Sep 23, 2020
1 parent 9006261 commit 03ed3f9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion image_proc/src/nodelets/debayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,16 @@ void DebayerNodelet::imageCb(const sensor_msgs::ImageConstPtr& raw_msg)
if (algorithm == Debayer_VNG)
code += cv::COLOR_BayerBG2BGR_VNG - cv::COLOR_BayerBG2BGR;

cv::cvtColor(bayer, color, code);
try
{
cv::cvtColor(bayer, color, code);
}
catch (cv::Exception &e)
{
NODELET_WARN_THROTTLE(30, "cvtColor error: '%s', bayer code: %d, width %d, height %d",
e.what(), code, bayer.cols, bayer.rows);
return;
}
}

pub_color_.publish(color_msg);
Expand Down

0 comments on commit 03ed3f9

Please sign in to comment.