cv::bilateralFilter segfaults on image from cv_bridge
I have a ROS node that takes in a depth image and converts it to an openCV compatible format. However it doesn't seem to be compatible with all openCV functions.
cv_bridge::CvImagePtr bridge;
try
{
bridge = cv_bridge::toCvCopy(msg, "32FC1");
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("Failed to transform depth image.");
return;
}
depthImage = bridge->image;
cv::Mat depthImageFiltered(480,640,CV_32F);
cv::bilateralFilter( depthImage, depthImageFiltered, -1, 0.45, 3.0 );
This produces a segmentation fault on the last line whereas
cv::blur( depthImage, depthImageFiltered, cv::Size(5,5));
works without error. I see no reason why these two should behave differently. Weirder still, the bilateralFilter works fine with floating-point images loaded through cv::imread(). What am I doing wrong?