A question about Image message formats
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
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.
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
sorry, I misunderstood your question. The
encoding
field of theImage
message (mostly) tells you the format ofdata[]
. There is a list of pre-defined strings, wherebgr8
is probably the most common.