follower_opencv.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 #This script uses the cv_bridge package to convert images coming on the topic
00004 #sensor_msgs/Image to OpenCV messages and display them on the screen
00005 
00006 import rospy
00007 from sensor_msgs.msg import Image
00008 import cv2, cv_bridge
00009 class Follower:
00010         def __init__(self):
00011                 self.bridge = cv_bridge.CvBridge()
00012                 cv2.namedWindow("window", 1)
00013                 self.image_sub = rospy.Subscriber('camera/rgb/image_raw',
00014                 Image, self.image_callback)
00015         
00016         def image_callback(self, msg):
00017                 image = self.bridge.imgmsg_to_cv2(msg,desired_encoding='bgr8')
00018                 cv2.imshow("window", image)
00019                 cv2.waitKey(3)
00020 rospy.init_node('follower')
00021 follower = Follower()
00022 rospy.spin()


gapter
Author(s):
autogenerated on Thu Jun 6 2019 22:05:13