how to convert a 32FC1 image message to color formats?
thachdo opened this issue · 1 comments
thachdo commented
Hello,
Can we convert a 32FC1 image message to color formats like rbg8 or bgr8?
I'm using the below function
cv_bridge::CvImagePtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvCopy(gray_msg, sensor_msgs::image_encodings::BGR8);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
and get below error:
[ERROR] [1668071878.177947865]: cv_bridge exception: [32FC1] is not a color format. but [bgr8] is. The conversion does not make sense
Is there a way to convert a gray image message to a color one directly?
ijnek commented
I'm going to assume you want to convert gray image to color image for display purposes. You could use cvtColorForDisplay
, and must specify how you want to convert the grayscale to the color format with the CvtColorForDisplayOptions
parameter.
vision_opencv/cv_bridge/include/cv_bridge/cv_bridge.hpp
Lines 288 to 322 in c620dd9