desktopCamCallib.py
Go to the documentation of this file.
00001 #
00002 # Copyright (c) 2010, Georgia Tech Research Corporation
00003 # All rights reserved.
00004 #
00005 # Redistribution and use in source and binary forms, with or without
00006 # modification, are permitted provided that the following conditions are met:
00007 #     * Redistributions of source code must retain the above copyright
00008 #       notice, this list of conditions and the following disclaimer.
00009 #     * Redistributions in binary form must reproduce the above copyright
00010 #       notice, this list of conditions and the following disclaimer in the
00011 #       documentation and/or other materials provided with the distribution.
00012 #     * Neither the name of the Georgia Tech Research Corporation nor the
00013 #       names of its contributors may be used to endorse or promote products
00014 #       derived from this software without specific prior written permission.
00015 #
00016 # THIS SOFTWARE IS PROVIDED BY GEORGIA TECH RESEARCH CORPORATION ''AS IS'' AND
00017 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 # DISCLAIMED. IN NO EVENT SHALL GEORGIA TECH BE LIABLE FOR ANY DIRECT, INDIRECT,
00020 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00021 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00022 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00023 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00024 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00025 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 #
00027 
00028 #  \author Travis Deyle (Healthcare Robotics Lab, Georgia Tech.)
00029 #  \author Martin Schuster (Healthcare Robotics Lab, Georgia Tech.)
00030 
00031 import roslib; roslib.load_manifest('laser_camera_segmentation')
00032 
00033 if __name__ == '__main__':
00034     import scanr_transforms as trs
00035     import transforms as tr
00036     import numpy as np,math
00037     import webcam_config as cc
00038     import opencv as cv
00039     import opencv.highgui as hg
00040     import hrl_lib.util as ut
00041     import tilting_hokuyo.processing_3d as p3d
00042     import laser_cam_callib
00043     import pygame
00044 
00045     #seeds = np.array([1.0, 0.9, -1.7, 3.1, 0.061, 0.032, -0.027 ])
00046     #seeds = np.array([0.0, 0.0, -0.0, 0.0, 0.061, 0.032, -0.027 ])
00047    
00048     
00049     #seeds = np.array([0.8, 0.9, -1.7, 3.1, 0.061, 0.032, -0.035 ])
00050     
00051     #seeds = np.array([2.4000  ,  3.8000  , -2.9000   , 5.5000  ,  0.0600  ,  0.0300  , -0.0430  ])
00052    # seeds = np.array([2.2000  ,  2.0000  , -2.8000  ,  5.5000  ,   0.0500  ,  0.0300  , -0.0430    ])
00053 # 2.0000    2.0000   -2.8000    5.5000    0.0550    0.0300  x  -0.0400
00054     #seeds = np.array([0.9000  ,  0.8000 ,  -2.2000 ,   3.1000 ,   0.0620 ,   0.0320,   -0.0270 ])
00055     seeds = np.array([  1.8000  ,  1.7000  , -2.6000 ,   4.7500 ,   0.0620  ,  0.0320  , -0.0270  ])
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063     
00064     deltas = np.array([0.1, 0.1, 0.1, 0.1, 0.001, 0.001, 0.001 ])
00065     #-1.0000  x   1.7000   -2.2000    6.4000   -0.0200    0.0300   -0.0430  
00066 
00067     names = ['Ry_0', 'Rz_0', 'Rx_-90', 'Rz_-90', 'dx', 'dy', 'dz']
00068 
00069 
00070     def camTlaser( res = np.zeros(6) ):
00071         rot = tr.Ry( math.radians( 0.0 + res[0] )) * tr.Rz( math.radians( 0.0 + res[1] )) * tr.Rx( math.radians( -90.0 + res[2] )) * tr.Rz( math.radians( -90.0 + res[3]))
00072         disp = np.matrix([ res[4], res[5], res[6] ]).T + np.matrix([ 0.0, 0.0, 0.0 ]).T
00073         return tr.composeHomogeneousTransform(rot, disp)
00074 
00075     cameraTlaser = trs.camTlaser
00076 
00077     cp = cc.webcam_parameters['DesktopWebcam']
00078     fx = cp['focal_length_x_in_pixels']
00079     fy = cp['focal_length_y_in_pixels']
00080     cam_proj_mat =  np.matrix([[fx, 0, 0,   0],
00081                                [0, fy, 0,   0],
00082                                [0,  0, 1,   0]])
00083 
00084     cam_centers = ( cp['optical_center_x_in_pixels'], cp['optical_center_y_in_pixels'] )
00085 
00086     
00087     #take image and scan
00088     import scanner  
00089     import configuration    
00090     #id = '2009Nov04_144041'
00091     id = '2009Nov04_135319'
00092     
00093     cfg = configuration.configuration('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/labeling')
00094     img = hg.cvLoadImage(cfg.path + '/data/' + id + '_image.png')
00095     thok_dict = ut.load_pickle(cfg.path + '/data/' + id + '_laserscans.pkl')
00096     #cfg = configuration.configuration('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/calib')
00097     #cfg.webcam_id = 0
00098     #sc = scanner.scanner(cfg)
00099     #sc.capture_and_save('calib', False)
00100     #img = hg.cvLoadImage('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/calib/data/calib_image.png')
00101     #thok_dict = ut.load_pickle('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/calib/data/calib_laserscans.pkl')
00102     poses, scans = thok_dict['laserscans'][0]
00103     points_cloud_laser = p3d.generate_pointcloud(poses, scans, math.radians(-180), math.radians(180), 
00104                                 0, .035, max_dist=5.0, min_dist=.1)
00105 
00106     c = laser_cam_callib.Callib(cameraTlaser, seeds, deltas, names, points_cloud_laser, img, cam_proj_mat, cam_centers,1, id)
00107     
00108     while not c.reDraw():
00109         tmp = 1
00110 
00111     pygame.quit()
00112     


laser_camera_segmentation
Author(s): Martin Schuster, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 11:56:44