Exemplo n.º 1
0
    def __init__(self):
        rospy.init_node('viewer', anonymous=True)

        image_topic = rospy.get_param('~image', '/ueye/image')
        # Pattern parameters
        pattern_rows = rospy.get_param('~pattern_rows', 7)
        pattern_cols = rospy.get_param('~pattern_cols', 8)
        pattern_size = rospy.get_param('~pattern_size', 10)

        config_file = rospy.get_param('~config', 'profile3d.yaml')

        rospy.Subscriber(image_topic, Image, self.callback, queue_size=10)
        rospy.on_shutdown(self.on_shutdown_hook)

        self.counter = 0
        self.bridge = CvBridge()
        self.listener = tf.TransformListener()

        self.square_size = pattern_size
        self.grid_size = (pattern_cols - 1, pattern_rows - 1)

        self.laser_profile = Profile(axis=1, thr=180, method='pcog')
        self.camera_calibration = CameraCalibration(
            grid_size=self.grid_size, square_size=self.square_size)

        cv2.namedWindow('viewer')
        cv2.cv.SetMouseCallback('viewer', self.on_mouse, '')

        rospy.spin()
Exemplo n.º 2
0
np.set_printoptions(precision=4, suppress=True)

path = '../'
pattern_rows = 7
pattern_cols = 8
pattern_size = 0.010
config_file = 'profile3d.yaml'

dirname = '../data'
images, tool_poses = read_calibration_data(dirname)

square_size = pattern_size
grid_size = (pattern_cols - 1, pattern_rows - 1)

laser_profile = Profile(axis=1, thr=180, method='pcog')
camera_calibration = CameraCalibration(grid_size=grid_size,
                                       square_size=square_size)
laser_calibration = LaserCalibration(grid_size=grid_size,
                                     square_size=square_size,
                                     profile=laser_profile)
laser_calibration.find_calibration_3d(images)
laser_calibration.save_parameters(os.path.join(path, 'config', config_file))

filenames = sorted(glob.glob('../data/pose*.txt'))
ks = [int(filename[-8:-4]) for filename in filenames]
poses_checker, poses_tool = [], []
poses_ichecker, poses_itool = [], []
for k in ks:
    print 'Frame: %i' % k
    img = read_image('../data/frame%04i.png' % k)
    grid = camera_calibration.find_chessboard(img)
    pose_checker = None