Go to the documentation of this file.00001
00002 import roslib; roslib.load_manifest('projector_calibration')
00003 import rospy
00004 import cv2
00005 from sensor_msgs.msg import RegionOfInterest, Image
00006 from cv_bridge import CvBridge, CvBridgeError
00007 import numpy as np
00008 bridge = CvBridge()
00009 roi_pub = None
00010 def img_cb(msg):
00011 cv2.imshow('win', np.asarray(bridge.imgmsg_to_cv(msg)))
00012 cv2.waitKey(10)
00013
00014 def click(s, x, y, click, u):
00015 if click:
00016 roi = RegionOfInterest()
00017
00018 roi.x_offset = x
00019 roi.y_offset = y
00020
00021
00022 roi_pub.publish(roi)
00023 print roi.x_offset, roi.y_offset
00024
00025 if __name__ == '__main__':
00026 cv2.namedWindow('win')
00027 cv2.setMouseCallback('win', click)
00028 rospy.init_node('projector_test')
00029 rospy.Subscriber('image', Image, img_cb)
00030 roi_pub = rospy.Publisher('roi', RegionOfInterest)
00031 rospy.spin()
00032 cv2.destroyAllWindows()