Ask Your Question
0

Destination encoding for ros image to opencv image conversion [closed]

asked 2016-08-10 15:16:24 -0500

skr_robo gravatar image

I am trying to create an OpenCV image from a ros image using this . I am subscribing to a topic /camera/depth/img_rect_color which is of the type sensor_msgs/Image with 32FC1 encoding. How do I specify destination encoding in the following line:

cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::32FC1);

If I specify 32FC1, it gives the error :

error: invalid suffix "FC1" on integer constant
       cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::32FC1);
                                                                       ^
/home/ubuntu/tst_ws/src/roscv_conv/src/roscv_conv_node.cpp: In member function 'void ImageConverter::imageCb(const ImageConstPtr&)':
/home/ubuntu/tst_ws/src/roscv_conv/src/roscv_conv_node.cpp:39:71: error: expected unqualified-id before numeric constant

How can I rectify this?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by skr_robo
close date 2016-08-10 15:20:59.210525

1 Answer

Sort by » oldest newest most voted
0

answered 2016-08-10 15:20:24 -0500

skr_robo gravatar image

Rectified the issue by changing the line as:

cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::TYPE_32FC1);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-10 15:16:24 -0500

Seen: 94 times

Last updated: Aug 10 '16