Ask Your Question

subscribe sensor_message/Image without opencv

asked 2019-08-31 06:00:09 -0500

GXY gravatar image

I would like to print(or just read) the content(i.e. the 'data' field) of a ROS topic of type "sensor_message/Image", but without OpenCV(for performance consideration). Here is a snippet of some naive codes that I've tried:

#!/usr/bin/env python
PKG = 'numpy_tutorial'
import roslib; roslib.load_manifest(PKG)
import rospy 
from sensor_msgs.msg import Image 

def callback(Image):
    print (

def listener():
    rospy.Subscriber('/camera/color/image_raw', Image, callback)

if __name__ == '__main__':

But it just prints some unreadable characters in console, I anticipated that it's not just 'print(', but how can I do it correctly in python? besides, my ultimate goal is to transform 'data' to numpy array format.

Many thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-09-01 09:48:58 -0500

pavel92 gravatar image

This question contains answers that might solve your problem.

edit flag offensive delete link more


thanks, it worked

GXY gravatar image GXY  ( 2019-09-07 13:29:48 -0500 )edit

I am glad it helped, you can accept the answer as correct in that case

pavel92 gravatar image pavel92  ( 2019-09-08 12:12:21 -0500 )edit

Sorry, may I also ask how to accept an answer here?

GXY gravatar image GXY  ( 2019-09-10 12:18:14 -0500 )edit

You can mark the answer as correct by clicking the tick mark just left of the answer

pavel92 gravatar image pavel92  ( 2019-09-11 03:05:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-08-31 06:00:09 -0500

Seen: 111 times

Last updated: Sep 01 '19