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

Revision history [back]

click to hide/show revision 1
initial version

The depth of your image message is not necessarily 8-bits. You need to look at the meta-data fields at the start of the Image message:

uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data

To allow this message to support many varied formats, that data field is a binary blob that must be parsed using the meta-data to turn it back into actual rectangular Image data.

The depth of your image message is not necessarily 8-bits. You need to look at the meta-data fields at the start of the Image message:

uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data

To allow this message to support many varied formats, that data field is a binary blob that must be parsed using the meta-data to turn it back into actual rectangular Image data.

Update: the routines to do this parsing are provided by ROS. The first step for most is to convert the Image message into an open-cv2 2d array. See packages cv2 and cv_bridge. In python, the call looks like this:

cv_img = bridge.imgmsg_to_cv2(msg, 'bgr8')

The depth of your image message is not necessarily 8-bits. You need to look at the meta-data fields at the start of the Image message:

uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data

To allow this message to support many varied formats, that data field is a binary blob that must be parsed using the meta-data to turn it back into actual rectangular Image data.

Update: the routines to do this parsing are provided by ROS. The first step for most is to convert the Image message into an open-cv2 2d opencv v2 2D array. See packages cv2 and cv_bridge. In python, the call looks like this:

cv_img = bridge.imgmsg_to_cv2(msg, 'bgr8')

The depth of your image message is not necessarily 8-bits. You need to look at the meta-data fields at the start of the Image message:

uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data

To allow this message to support many varied formats, that data field is a binary blob that must be parsed using the meta-data to turn it back into actual rectangular Image data.

Update: the routines to do this parsing are provided by ROS. The first step for most is to convert the Image message into an opencv v2 2D multi-dimensional array. See packages cv2 and cv_bridge. In python, the call looks like this:

cv_img = bridge.imgmsg_to_cv2(msg, 'bgr8')