Extract data from Image.msg
I need to process the data from a webcam (i used USB_CAM Package).
Initially I created a listener that from the topic "/usb_cam/image_raw" extrapolates the array uint8 [] data ... but ...
Here's the python code:
# / usr / bin / env python
import roslib; roslib.load_manifest ('webcam_image')
import rospy
Image import from sensor_msgs.msg
def callback (date):
print "I heard% s"% str (Image.data)
def listener ():
rospy.init_node ('read_data', anonymous = True)
rospy.Subscriber ("usb_cam / image_raw", Image, callback)
rospy.spin ()
if __ name__ == '__main__':
listener ()
And there the output on the shell when I start:
I heard < member'data' of'Image' objects>
If i write:
rostopic echo /usb_cam/image_raw
appears correctly:
header:
seq: 491
stamp:
secs: 1372323952
nsecs: 364679466
frame_id: usb_cam
height: 4
width: 4
encoding: rgb8
is_bigendian: 0
step: 12
data: [103, 111, 98, 104, 112, 99, 102, 110, 104, 103, 111, 105, 100, 112, 100, 101, 113, 101, 103, 109, 107, 102, 108, 106, 101, 108, 108, 102, 109, 109, 102, 109, 109, 102, 109, 109, 103, 110, 102, 102, 109, 101, 105, 113, 100, 100, 108, 95]
What could be wrong?
I've to send image data to LabVIEW via Rosbridge and Clearpath Toolkit. The problem is that the image is not well understood in the passage, so i'm trying to process the image data to transform the array in a string, and send it by a specific topic. But first i'm to extract data from Image.msg