42 import sensor_msgs.msg
43 from cv_bridge
import CvBridge
50 self.
pub = rospy.Publisher(
"/opencv_tests/images", sensor_msgs.msg.Image)
51 self.
pub_compressed = rospy.Publisher(
"/opencv_tests/images/compressed", sensor_msgs.msg.CompressedImage)
57 cvim = numpy.zeros((480, 640, 1), numpy.uint8)
65 while not rospy.core.is_shutdown():
68 cv2.circle(cvim, (ball_x, ball_y), 10, 255, -1)
72 if ball_x
in [10, 630]:
74 if ball_y
in [10, 470]:
77 self.pub.publish(cvb.cv2_to_imgmsg(cvim))
78 self.pub_compressed.publish(cvb.cv2_to_compressed_imgmsg(cvim))
84 rospy.init_node(
'Source')
88 outcome =
'test completed' 89 except KeyboardInterrupt:
91 outcome =
'keyboard interrupt' 92 rospy.core.signal_shutdown(outcome)
94 if __name__ ==
'__main__':