sensor_msgs/Image data value is a string?
I've written a node in python to read a binary image (of type sensor_msgs/Image) being published on a topic. I got confused when trying to access the data in the callback.
print img
produces
header:
seq: 35232
stamp:
secs: 0
nsecs: 0
frame_id: ''
height: 40
width: 127
encoding: 8UC3
is_bigendian: 0
step: 381
data: [0, 0, 0, 0, ...]
I shortened the data array with an ellipsis.
What's weird are the types of the data.
print type(img.data), type(img.data[0])
produces
<type 'str'> <type 'str'>
When I try to display the data with "print img.data" I get a bunch of junk characters. When I try to index into the first element, I get an empty string.
This confuses me because the description of the topic type Image specifies that the img.data field is an array of bytes. Why am I seeing a string here?