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

Extract data from Image.msg

asked 2013-06-26 23:16:05 -0500

MarcoTe6 gravatar image

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?

edit retag flag offensive close merge delete

Comments

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

MarcoTe6 gravatar image MarcoTe6  ( 2013-06-28 02:15:30 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-06-26 23:22:40 -0500

davinci gravatar image

What is the problem exactly? ROS uses an imagetransport method for images, not a regular topic. Images can be viewed using rosrun image_view image_view image:=/usb_cam/image_raw

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-06-26 23:16:05 -0500

Seen: 874 times

Last updated: Jun 26 '13