6 from distutils.version
import LooseVersion
8 if LooseVersion(scipy.__version__) >= LooseVersion(
"0.17"):
9 from scipy.misc
import ascent
11 from scipy.misc
import lena
14 from sensor_msgs.msg
import Image
19 pub = rospy.Publisher(
'image', Image, queue_size=1)
21 if LooseVersion(scipy.__version__) >= LooseVersion(
"0.17"):
22 img = cv2.cvtColor(ascent().astype(np.uint8), cv2.COLOR_GRAY2BGR)
24 img = cv2.cvtColor(lena().astype(np.uint8), cv2.COLOR_GRAY2BGR)
26 bridge = cv_bridge.CvBridge()
27 msg = bridge.cv2_to_imgmsg(img, encoding=
'bgr8')
28 msg.header.frame_id =
'camera' 31 while not rospy.is_shutdown():
32 msg.header.stamp = rospy.get_rostime()
37 if __name__ ==
'__main__':
38 rospy.init_node(
'publish_lena')