ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

A question about Image message formats

asked 2021-07-31 18:01:28 -0500

Kansai gravatar image

If I have a opencv Image I can check its format with image.shape and image.dtype to see if it is for example 8 bits unsigned with four channels.

Later when I convert it to a ROS image message, or if a subscriber receives a ROS image message, is there a way to check its format that does not involve conversion to opencv images?

Also in Cvbridge when doing bridge.imgmsg_to_cv2(image_message, desired_encoding='passthrough') it says that "passthrough" keeps the encoding but in the other way around bridge.cv2_to_imgmsg(cv_image, encoding="passthrough") what does passthrough means exactly. A better explanation is needed please

edit retag flag offensive close merge delete

Comments

In the future, please ask only 1 question per post.

Regarding the first question, I'm puzzled why your code would want to do that. If conversion is required, is your code going to discard the image? This idea strikes me as very close to the "premature optimization" line.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-08-01 11:50:08 -0500 )edit

I am sorry, I don't understand your comment. The code is standard as put in the ROS cvbridge tutorial. We have one opencv image and we convert it to a ros image message. In the tutorial that is standard. Just as we can check the format of the opencv image I am asking if we can check the ros image format as well

Kansai gravatar image Kansai  ( 2021-08-02 01:19:19 -0500 )edit
1

sorry, I misunderstood your question. The encoding field of the Image message (mostly) tells you the format of data[]. There is a list of pre-defined strings, where bgr8 is probably the most common.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-08-02 07:14:48 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-08-04 08:14:22 -0500

Mike Scheutzow gravatar image

The encoding field of the Image message (mostly) tells you the format of data[]. There is a list of pre-defined strings, where bgr8 is probably the most common.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-07-31 18:01:28 -0500

Seen: 286 times

Last updated: Aug 04 '21