subscribe sensor_message/Image without opencv
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 (Image.data)
def listener():
rospy.init_node('listener')
rospy.Subscriber('/camera/color/image_raw', Image, callback)
rospy.spin()
if __name__ == '__main__':
listener()
But it just prints some unreadable characters in console, I anticipated that it's not just 'print(Image.data)', 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!