コード例 #1
0
def testPlanePointcloud():
    import roslib
    roslib.load_manifest('laser_camera_segmentation')
    import laser_camera_segmentation.processor as processor
    import laser_camera_segmentation.configuration as configuration

    cfg = configuration.configuration(
        '/home/martin/robot1_data/usr/martin/laser_camera_segmentation/labeling'
    )
    #sc = scanner.scanner(cfg)
    pc = processor.processor(cfg)
    #pc.load_data('2009Oct30_162400')
    pc.load_data('2009Nov04_141226')
    pc.process_raw_data()

    debug = False
    model = PlaneLeastSquaresModel(debug)
    data = numpy.asarray(pc.pts3d_bound).T
    # run RANSAC algorithm
    ransac_fit, ransac_data = ransac(
        data,
        model,
        3,
        1000,
        0.02,
        300,  # misc. parameters
        debug=debug,
        return_all=True)
    print ransac_fit
    print ransac_data
    print 'len inlier', len(ransac_data['inliers']), 'shape pts', np.shape(
        pc.pts3d_bound)
    pc.pts3d_bound = pc.pts3d_bound[:, ransac_data['inliers']]
    pc.display_3d('height')
コード例 #2
0
def get_test_data():
    cfg = configuration.configuration("../data/ROS_test_client/", "dummyScanner")
    pc = processor.processor(cfg)
    pc.scan_dataset = scan_dataset()
    pc.scan_dataset.image_artag_filename = ""
    pc.scan_dataset.table_plane_translation = np.matrix([0, 0, 0]).T
    # approximate height of hokuyo above the ground, assume it to be fixed for now.
    pc.scan_dataset.ground_plane_translation = np.matrix([0, 0, 1.32]).T
    pc.scan_dataset.ground_plane_rotation = ""
    # pc.scan_dataset.is_test_set = True
    pc.scan_dataset.is_labeled = True
    pc.scan_dataset.id = "ROStest"
    pc.load_raw_data(pc.scan_dataset.id)
    image_size = cv.cvGetSize(pc.img)

    # don't do any mapping to not change the pts3d!
    # create point cloud from raw range points
    (pc.pts3d, pc.scan_indices, pc.intensities) = pc.create_pointcloud(pc.laserscans, True, True)

    # region of interest in image pixels
    polygon = label_object()
    polygon.set_label("surface")
    width_min = image_size.width * 0.4
    width_max = image_size.width * 0.95
    height_min = image_size.height * 0.3
    height_max = image_size.height * 0.95
    polygon.add_point((width_min, height_min))
    polygon.add_point((width_min, height_max))
    polygon.add_point((width_max, height_max))
    polygon.add_point((width_max, height_min))

    return pc.pts3d, pc.intensities, None, pc.img, pc.image_angle, polygon
コード例 #3
0
def get_test_data():
    cfg = configuration.configuration('../data/ROS_test_client/',
                                      'dummyScanner')
    pc = processor.processor(cfg)
    pc.scan_dataset = scan_dataset()
    pc.scan_dataset.image_artag_filename = ''
    pc.scan_dataset.table_plane_translation = np.matrix([0, 0, 0]).T
    #approximate height of hokuyo above the ground, assume it to be fixed for now.
    pc.scan_dataset.ground_plane_translation = np.matrix([0, 0, 1.32]).T
    pc.scan_dataset.ground_plane_rotation = ''
    #pc.scan_dataset.is_test_set = True
    pc.scan_dataset.is_labeled = True
    pc.scan_dataset.id = 'ROStest'
    pc.load_raw_data(pc.scan_dataset.id)
    image_size = cv.cvGetSize(pc.img)

    #don't do any mapping to not change the pts3d!
    #create point cloud from raw range points
    (pc.pts3d, pc.scan_indices,
     pc.intensities) = pc.create_pointcloud(pc.laserscans, True, True)

    #region of interest in image pixels
    polygon = label_object()
    polygon.set_label('surface')
    width_min = image_size.width * 0.4
    width_max = image_size.width * 0.95
    height_min = image_size.height * 0.3
    height_max = image_size.height * 0.95
    polygon.add_point((width_min, height_min))
    polygon.add_point((width_min, height_max))
    polygon.add_point((width_max, height_max))
    polygon.add_point((width_max, height_min))

    return pc.pts3d, pc.intensities, None, pc.img, pc.image_angle, polygon
コード例 #4
0
ファイル: ransac.py プロジェクト: gt-ros-pkg/hrl
def testPlanePointcloud():
    import roslib; roslib.load_manifest('laser_camera_segmentation')
    import laser_camera_segmentation.processor as processor
    import laser_camera_segmentation.configuration as configuration    

    cfg = configuration.configuration('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/labeling')
    #sc = scanner.scanner(cfg)
    pc = processor.processor(cfg)
    #pc.load_data('2009Oct30_162400')
    pc.load_data('2009Nov04_141226')
    pc.process_raw_data()
    
    
    debug = False
    model = PlaneLeastSquaresModel(debug)
    data = numpy.asarray(pc.pts3d_bound).T
    # run RANSAC algorithm
    ransac_fit, ransac_data = ransac(data,model,
                                     3, 1000, 0.02, 300, # misc. parameters
                                     debug=debug,return_all=True)
    print ransac_fit
    print ransac_data    
    print 'len inlier',len(ransac_data['inliers']),'shape pts',np.shape(pc.pts3d_bound)
    pc.pts3d_bound = pc.pts3d_bound[:,ransac_data['inliers']]
    pc.display_3d('height')
コード例 #5
0
def test_segmentation():
    rospy.wait_for_service('segment_pointcloud')
    try:
        pts3d, intensities, labels, image, image_angle, polygon = get_test_data(
        )
        ROS_pointcloud = convert_pointcloud_to_ROS(pts3d, intensities, labels)
        ROS_image = convert_cvimage_to_ROS(image)
        imageSize = cv.cvGetSize(image)

        ROS_polygon = convert_polygon_to_ROS(polygon)

        segment_pointcloud = rospy.ServiceProxy('segment_pointcloud',
                                                Segmentation)
        request = SegmentationRequest()
        request.imageWidth = 41
        request.pointcloud = ROS_pointcloud
        request.image = ROS_image
        request.imageWidth = imageSize.width
        request.imageHeight = imageSize.height
        request.imageAngle = image_angle
        request.regionOfInterest2D = ROS_polygon
        request.laserHeightAboveGround = 1.32
        request.numberOfPointsToClassify = 1000  #-1 == all

        response = segment_pointcloud(request)

        pts3d_bound, intensities, labels = convert_ROS_pointcloud_to_pointcloud(
            response.pointcloud)
        cfg = configuration.configuration('../data/ROS_test_client/',
                                          'dummyScanner')
        pc = processor.processor(cfg)

        pc.scan_dataset = scan_dataset()
        pc.scan_dataset.image_artag_filename = ''
        pc.scan_dataset.table_plane_translation = np.matrix([0, 0, 0]).T

        pc.scan_dataset.ground_plane_translation = np.matrix(
            [0, 0, request.laserHeightAboveGround]).T
        pc.scan_dataset.ground_plane_rotation = ''
        pc.scan_dataset.is_labeled = True
        pc.scan_dataset.id = 'ROStest'
        pc.image_angle = ''
        pc.pts3d_bound = pts3d_bound
        pc.map_polys = labels
        pc.scan_dataset.ground_plane_normal = np.matrix([0., 0., 1.]).T

        from enthought.mayavi import mlab
        pc.display_3d('labels')
        mlab.show()

        return response
    except rospy.ServiceException, e:
        print "Service call failed: %s" % e
コード例 #6
0
ファイル: laser_cam_callib.py プロジェクト: gt-ros-pkg/hrl
 def display3d(self):
     import laser_camera_segmentation.processor as processor
     import laser_camera_segmentation.configuration as configuration       
     print 'display in 3d...'
     cfg = configuration.configuration('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/labeling')
     cfg.cam_vec = np.array(self.vals)
     import scanr_transforms as trs
     cfg.camTlaser = trs.camTlaser(cfg.cam_vec)
     
     pc = processor.processor(cfg)
     pc.load_data(self.dataset_id)
     pc.process_raw_data()
     pc.display_3d('labels', False)        
コード例 #7
0
def segment_pointcloud(request):
    #convert data from ROS
    pts3d, intensities, labels = convert_ROS_pointcloud_to_pointcloud(
        request.pointcloud)
    cvimage = convert_ROS_image_to_cvimage(request.image, request.imageWidth,
                                           request.imageHeight)
    polygon = convert_ROS_polygon_to_polygon(request.regionOfInterest2D)
    polygon.set_label('surface')
    print polygon, polygon.get_points()

    #create processor and configuration
    #cfg = configuration.configuration('/home/martin/robot1_data/usr/martin/ROS_server_test', 'codyRobot')
    cfg = configuration.configuration('../data/ROS_server', 'dummyScanner')
    pc = processor.processor(cfg)

    pc.scan_dataset = scan_dataset()
    pc.scan_dataset.image_artag_filename = ''
    pc.scan_dataset.table_plane_translation = np.matrix([0, 0, 0]).T

    pc.scan_dataset.ground_plane_translation = np.matrix(
        [0, 0, request.laserHeightAboveGround]).T
    pc.scan_dataset.ground_plane_rotation = ''
    #pc.scan_dataset.is_test_set = True
    pc.scan_dataset.is_labeled = True
    pc.scan_dataset.id = 'ROStest'

    pc.img = cvimage
    pc.image_angle = request.imageAngle
    pc.pts3d = pts3d
    pc.intensities = intensities
    pc.scan_indices = np.zeros(len(intensities))

    pc.scan_dataset.polygons.append(polygon)
    pc.do_all_point_cloud()
    pc.do_polygon_mapping()

    pc.scan_dataset.ground_plane_normal = np.matrix([0., 0., 1.]).T

    if request.numberOfPointsToClassify == -1:
        n = 999999999999
    else:
        n = request.numberOfPointsToClassify
    feature_data = pc.generate_features(n, False, True)
    labels, testresults = pc.load_classifier_and_test_on_dataset(
        'all_post', feature_data)

    response = SegmentationResponse()
    response.pointcloud = convert_pointcloud_to_ROS(pc.pts3d_bound,
                                                    pc.intensities_bound,
                                                    labels)
    return response
コード例 #8
0
def test_segmentation():
    rospy.wait_for_service("segment_pointcloud")
    try:
        pts3d, intensities, labels, image, image_angle, polygon = get_test_data()
        ROS_pointcloud = convert_pointcloud_to_ROS(pts3d, intensities, labels)
        ROS_image = convert_cvimage_to_ROS(image)
        imageSize = cv.cvGetSize(image)

        ROS_polygon = convert_polygon_to_ROS(polygon)

        segment_pointcloud = rospy.ServiceProxy("segment_pointcloud", Segmentation)
        request = SegmentationRequest()
        request.imageWidth = 41
        request.pointcloud = ROS_pointcloud
        request.image = ROS_image
        request.imageWidth = imageSize.width
        request.imageHeight = imageSize.height
        request.imageAngle = image_angle
        request.regionOfInterest2D = ROS_polygon
        request.laserHeightAboveGround = 1.32
        request.numberOfPointsToClassify = 1000  # -1 == all

        response = segment_pointcloud(request)

        pts3d_bound, intensities, labels = convert_ROS_pointcloud_to_pointcloud(response.pointcloud)
        cfg = configuration.configuration("../data/ROS_test_client/", "dummyScanner")
        pc = processor.processor(cfg)

        pc.scan_dataset = scan_dataset()
        pc.scan_dataset.image_artag_filename = ""
        pc.scan_dataset.table_plane_translation = np.matrix([0, 0, 0]).T

        pc.scan_dataset.ground_plane_translation = np.matrix([0, 0, request.laserHeightAboveGround]).T
        pc.scan_dataset.ground_plane_rotation = ""
        pc.scan_dataset.is_labeled = True
        pc.scan_dataset.id = "ROStest"
        pc.image_angle = ""
        pc.pts3d_bound = pts3d_bound
        pc.map_polys = labels
        pc.scan_dataset.ground_plane_normal = np.matrix([0.0, 0.0, 1.0]).T

        from enthought.mayavi import mlab

        pc.display_3d("labels")
        mlab.show()

        return response
    except rospy.ServiceException, e:
        print "Service call failed: %s" % e
コード例 #9
0
    def display3d(self):
        import laser_camera_segmentation.processor as processor
        import laser_camera_segmentation.configuration as configuration
        print 'display in 3d...'
        cfg = configuration.configuration(
            '/home/martin/robot1_data/usr/martin/laser_camera_segmentation/labeling'
        )
        cfg.cam_vec = np.array(self.vals)
        import scanr_transforms as trs
        cfg.camTlaser = trs.camTlaser(cfg.cam_vec)

        pc = processor.processor(cfg)
        pc.load_data(self.dataset_id)
        pc.process_raw_data()
        pc.display_3d('labels', False)
コード例 #10
0
def segment_pointcloud(request):
    #convert data from ROS
    pts3d, intensities, labels = convert_ROS_pointcloud_to_pointcloud(request.pointcloud)
    cvimage = convert_ROS_image_to_cvimage(request.image, request.imageWidth, request.imageHeight)
    polygon = convert_ROS_polygon_to_polygon(request.regionOfInterest2D)
    polygon.set_label('surface')
    print polygon, polygon.get_points()
    
    #create processor and configuration
    #cfg = configuration.configuration('/home/martin/robot1_data/usr/martin/ROS_server_test', 'codyRobot')
    cfg = configuration.configuration('../data/ROS_server', 'dummyScanner')
    pc = processor.processor(cfg)
    
    pc.scan_dataset = scan_dataset()
    pc.scan_dataset.image_artag_filename = ''
    pc.scan_dataset.table_plane_translation = np.matrix([0,0,0]).T

    pc.scan_dataset.ground_plane_translation = np.matrix([0,0,request.laserHeightAboveGround]).T 
    pc.scan_dataset.ground_plane_rotation = ''
    #pc.scan_dataset.is_test_set = True
    pc.scan_dataset.is_labeled = True
    pc.scan_dataset.id = 'ROStest'
    
    pc.img = cvimage
    pc.image_angle = request.imageAngle
    pc.pts3d = pts3d
    pc.intensities = intensities
    pc.scan_indices = np.zeros(len(intensities))
    
    pc.scan_dataset.polygons.append(polygon)
    pc.do_all_point_cloud()
    pc.do_polygon_mapping()
    
    pc.scan_dataset.ground_plane_normal = np.matrix([0.,0.,1.]).T
    
    if request.numberOfPointsToClassify == -1:
        n = 999999999999
    else:
        n = request.numberOfPointsToClassify
    feature_data = pc.generate_features(n, False, True)
    labels, testresults = pc.load_classifier_and_test_on_dataset('all_post', feature_data)

    response = SegmentationResponse()
    response.pointcloud = convert_pointcloud_to_ROS(pc.pts3d_bound, pc.intensities_bound, labels)
    return response
コード例 #11
0
ファイル: test_crossvalidation.py プロジェクト: wklharry/hrl
    print "Psyco loaded"
except ImportError:
    pass

import time 
def getTime():
    return '['+time.strftime("%H:%M:%S", time.localtime())+']'
        
import subprocess        
   
print getTime(), 'start'    

import laser_camera_segmentation.processor as processor
import laser_camera_segmentation.configuration as configuration       
        
cfg = configuration.configuration('/home/martin/robot1_data/usr/martin/laser_camera_segmentation/labeling')
pc = processor.processor(cfg)

#pc.calculate_and_save_ground_and_table_transformations_for_all_scans(use_RANSAC_table_plane = False)

pc.generate_save_features(True, True)  


folds = 40       
for current_fold in range(folds): #test_crossvalidation_fold.py
    #output = subprocess.Popen(["python", 'test_crossvalidation_fold.py',str(current_fold)], stdout=subprocess.PIPE, env={"ROS_PACKAGE_PATH":"/home/martin/ros/pkgs:/home/martin/gt-ros-pkg/hrl:/home/martin/robot1/src:/home/martin/gt-ros-pkg/hrl:/home/martin/robot1/src:/home/martin/gt-ros-pkg/hrl:/home/martin/robot1/src", "ROS_ROOT":"/home/martin/ros/ros", "PYTHONPATH": "/home/martin/robot1/src/libraries:/home/martin/robot1/src/libraries/katana:/home/martin/robot1/src/libraries:/home/martin/robot1/src/libraries/katana:/home/martin/robot1/src/libraries:/home/martin/robot1/src/libraries/katana:/home/martin/ros/ros/core/roslib/src:/home/martin/robot1/src/libraries:/home/martin/robot1/src/libraries/katana:/usr/local/lib/python2.5/site-packages/m3rt/:/home/martin/gt-ros-pkg/hrl/segway_omni/src:/home/martin/gt-ros-pkg/hrl/hrl_opencv/src:/home/martin/gt-ros-pkg/hrl/force_torque/src:/home/martin/gt-ros-pkg/hrl/hrl_lib/src:/home/martin/gt-ros-pkg/hrl/zenither/src:/home/martin/gt-ros-pkg/hrl/robotis/src:/usr/local/lib/python2.5/site-packages/m3rt/:/home/martin/gt-ros-pkg/hrl/segway_omni/src:/home/martin/gt-ros-pkg/hrl/hrl_opencv/src:/home/martin/gt-ros-pkg/hrl/force_torque/src:/home/martin/gt-ros-pkg/hrl/hrl_lib/src:/home/martin/gt-ros-pkg/hrl/zenither/src:/home/martin/gt-ros-pkg/hrl/robotis/src:/usr/local/lib/python2.5/site-packages/m3rt/:/home/martin/gt-ros-pkg/hrl/segway_omni/src:/home/martin/gt-ros-pkg/hrl/hrl_opencv/src:/home/martin/gt-ros-pkg/hrl/force_torque/src:/home/martin/gt-ros-pkg/hrl/hrl_lib/src:/home/martin/gt-ros-pkg/hrl/zenither/src:/home/martin/gt-ros-pkg/hrl/robotis/src"}).communicate()[0]
    output = subprocess.Popen(["python", 'test_crossvalidation_fold.py',str(current_fold)]).communicate()[0]
    #print getTime(), output
    
    #todo: parallel: don't use communicate() but just create 3 processes with Popen and then wait for them with wait()
コード例 #12
0
ファイル: labeling_tool.py プロジェクト: gt-ros-pkg/hrl
    def __init__(self, path, parent=None):
        
        self.init_in_progress = True
        
        self.path = path
        
        # load configs for taking scans, etc:
        self.config = configuration.configuration(path)
        #create scanner and processor when needed:
        self.scanner = False
        self.processor = False
        
        # load database:
        self.scans_database = scans_database.scans_database()
        self.scans_database.load(path,'database.pkl')
        
        #get first dataset:
        self.current_dataset = self.scans_database.get_dataset(0)

        QtGui.QWidget.__init__(self, parent)
        self.setWindowTitle('labeling tool')
        

        left_layout = QtGui.QVBoxLayout()
        self.draw_widget = draw_widget(self.current_dataset.polygons, self.scans_database.get_path() + '/' + self.current_dataset.image_filename, self)
        
        title_layout = QtGui.QHBoxLayout()
        
        take_scan_button = QtGui.QPushButton('Scan')
        take_scan_button.setMaximumWidth(50)
        title_layout.addWidget(take_scan_button)
        self.connect(take_scan_button, QtCore.SIGNAL('clicked()'), self.slot_take_scan )      
        
        take_artag_image_button = QtGui.QPushButton('ARTag')
        take_artag_image_button.setMaximumWidth(50)
        title_layout.addWidget(take_artag_image_button)
        self.connect(take_artag_image_button, QtCore.SIGNAL('clicked()'), self.slot_take_artag_image )              
        
        button = QtGui.QPushButton('Import Img')
        title_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_import_image )                 
        
        label = QtGui.QLabel("View: ")
        title_layout.addWidget(label)
        self.display_3d_button = QtGui.QPushButton('3D')
        self.display_3d_button.setMaximumWidth(40)
        title_layout.addWidget(self.display_3d_button)
        self.connect(self.display_3d_button, QtCore.SIGNAL('clicked()'), self.slot_display_3d )
        
        combobox = QtGui.QComboBox()
        combobox.addItem("Height", QtCore.QVariant("height"))
        combobox.addItem("Intensities", QtCore.QVariant("intensities"))
        #combobox.addItem("objects", QtCore.QVariant("objects"))
        combobox.addItem("Labels", QtCore.QVariant("labels"))
        combobox.addItem("Classifier range", QtCore.QVariant("range"))
        combobox.addItem("Classifier color", QtCore.QVariant("color"))
        combobox.addItem("Classifier all", QtCore.QVariant("all"))
        combobox.addItem("Classifier all+post", QtCore.QVariant("all_post"))
        combobox.addItem("Baseline algo", QtCore.QVariant("baseline"))
        combobox.addItem("h", QtCore.QVariant("h"))
        combobox.addItem("s", QtCore.QVariant("s"))
        combobox.addItem("v", QtCore.QVariant("v"))
        self.connect(combobox, QtCore.SIGNAL('currentIndexChanged(int)'), self.slot_update_display_3d_type)  
        title_layout.addWidget(combobox)
        self.display_3d_type_combobox = combobox;        
        
        
        self.display_3d_spheres_button = QtGui.QPushButton('3D_Spheres')
        title_layout.addWidget(self.display_3d_spheres_button)
        self.connect(self.display_3d_spheres_button, QtCore.SIGNAL('clicked()'), self.slot_display_3d_spheres )                  
        self.display_intensity_button = QtGui.QPushButton('Intensity')
        self.display_intensity_button.setMaximumWidth(50)
        title_layout.addWidget(self.display_intensity_button)
        self.connect(self.display_intensity_button, QtCore.SIGNAL('clicked()'), self.slot_display_intensity )   
        self.display_features_button = QtGui.QPushButton('Features')
        title_layout.addWidget(self.display_features_button)
        self.display_features_button.setMaximumWidth(50)
        self.connect(self.display_features_button, QtCore.SIGNAL('clicked()'), self.slot_display_features )   
        self.display_labels_button = QtGui.QPushButton('Labels')
        title_layout.addWidget(self.display_labels_button)
        self.display_labels_button.setMaximumWidth(50)
        self.connect(self.display_labels_button, QtCore.SIGNAL('clicked()'), self.slot_display_labels )   
        self.display_stats_button = QtGui.QPushButton('Stats')
        title_layout.addWidget(self.display_stats_button)
        self.display_stats_button.setMaximumWidth(50)
        self.connect(self.display_stats_button, QtCore.SIGNAL('clicked()'), self.slot_display_stats )   
        self.display_global_stats_button = QtGui.QPushButton('Global Stats')
        title_layout.addWidget(self.display_global_stats_button)
        self.display_global_stats_button.setMaximumWidth(50)
        self.connect(self.display_global_stats_button, QtCore.SIGNAL('clicked()'), self.slot_display_global_stats )         
        
        self.line_edits = []
    
        self.add_line_edit('Title:',title_layout,'title')


        first_dataset_button = QtGui.QPushButton('<<')
        first_dataset_button.setMaximumWidth(30)
        title_layout.addWidget(first_dataset_button)
        self.connect(first_dataset_button, QtCore.SIGNAL('clicked()'), self.slot_first_dataset )
        prev_dataset_button = QtGui.QPushButton('<')
        prev_dataset_button.setMaximumWidth(30)
        title_layout.addWidget(prev_dataset_button)
        self.connect(prev_dataset_button, QtCore.SIGNAL('clicked()'), self.slot_prev_dataset )
        next_dataset_button = QtGui.QPushButton('>')
        next_dataset_button.setMaximumWidth(30)
        title_layout.addWidget(next_dataset_button)
        self.connect(next_dataset_button, QtCore.SIGNAL('clicked()'), self.slot_next_dataset )
        last_dataset_button = QtGui.QPushButton('>>')
        last_dataset_button.setMaximumWidth(30)
        title_layout.addWidget(last_dataset_button)
        self.connect(last_dataset_button, QtCore.SIGNAL('clicked()'), self.slot_last_dataset )        
        
        save_button = QtGui.QPushButton('Save')
        title_layout.addWidget(save_button)
        save_button.setMaximumWidth(50)
        self.connect(save_button, QtCore.SIGNAL('clicked()'), self.slot_save )
        
        delete_button = QtGui.QPushButton('Delete')
        title_layout.addWidget(delete_button)
        delete_button.setMaximumWidth(50)
        self.connect(delete_button, QtCore.SIGNAL('clicked()'), self.slot_delete )        
        
        
        self.connect(self.draw_widget, QtCore.SIGNAL('sigPolyChanged'), self.slot_update_polygons)
        self.connect(self.draw_widget, QtCore.SIGNAL('sigPolyLabelChanged'), self.slot_update_polygon_label)
        self.connect(self.draw_widget, QtCore.SIGNAL('sigDefineGroundPlane'), self.slot_define_ground_plane)

        left_layout.addLayout(title_layout)
        
        #second row:
        row2_layout = QtGui.QHBoxLayout()
        left_layout.addLayout(row2_layout)
        

        label = QtGui.QLabel("Id:")
        row2_layout.addWidget(label)        
        self.id_label = QtGui.QLabel("")
        row2_layout.addWidget(self.id_label)        
        
        self.add_line_edit('Surface: ID:',row2_layout,'surface_id')
        self.add_line_edit('Height',row2_layout,'surface_height')
        
        
        label = QtGui.QLabel("Type: ")
        row2_layout.addWidget(label)
        combobox = QtGui.QComboBox()
        combobox.addItem("Table Office", QtCore.QVariant("table_office"))
        combobox.addItem("Table Dorm", QtCore.QVariant("table_dorm"))
        combobox.addItem("Table House", QtCore.QVariant("table_house"))
        combobox.addItem("Shelf Office", QtCore.QVariant("shelf_office"))
        combobox.addItem("Shelf Dorm", QtCore.QVariant("shelf_dorm"))
        combobox.addItem("Shelf House", QtCore.QVariant("shelf_house"))
        self.connect(combobox, QtCore.SIGNAL('currentIndexChanged(int)'), self.slot_update_surface_type)  
        row2_layout.addWidget(combobox)
        self.surface_type_combobox = combobox;
        
        self.add_line_edit('Camera: Height:',row2_layout,'camera_height')
        self.add_line_edit('Camera: Angle:',row2_layout,'camera_angle')
        
        #####################################
        #thrid row:
        row3_layout = QtGui.QHBoxLayout()
        left_layout.addLayout(row3_layout)
        
        #checkboxes:
        button = QtGui.QPushButton("&gen'n'save features")
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_generate_save_features )        
        
        checkbox = QtGui.QCheckBox('&Training Set')
        row3_layout.addWidget(checkbox)
        self.connect(checkbox, QtCore.SIGNAL('stateChanged(int)'), self.slot_update_training_set)  
        self.checkbox_training_set = checkbox
        
        checkbox = QtGui.QCheckBox('Te&st Set')
        row3_layout.addWidget(checkbox)
        self.connect(checkbox, QtCore.SIGNAL('stateChanged(int)'), self.slot_update_test_set)
        self.checkbox_test_set = checkbox  
        
        checkbox = QtGui.QCheckBox('Labels, Groundp. checked')
        row3_layout.addWidget(checkbox)
        self.connect(checkbox, QtCore.SIGNAL('stateChanged(int)'), self.slot_update_is_labeled)
        self.checkbox_is_labeled = checkbox                         
        
        button = QtGui.QPushButton("Train'n'save Classifiers (training set)")
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_train_and_save_Classifiers )
        
        button = QtGui.QPushButton('Test Classifiers (on current)')
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_test_Classifiers )
        
        button = QtGui.QPushButton('Test Classifiers (on testset)')
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_test_Classifiers_on_testset )        
        
        button = QtGui.QPushButton('Load Classifiers')
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_load_Classifiers )
 
#        button = QtGui.QPushButton('Save Classifier')
#        row3_layout.addWidget(button)
#        self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_save_Classifier )                       
        
        #####################################
        
        left_layout.addWidget(self.draw_widget)
        
        
        self.right_layout = QtGui.QVBoxLayout()
        self.right_layout.setAlignment(QtCore.Qt.AlignTop)
        
        self.outer_layout = QtGui.QHBoxLayout()
        self.outer_layout.addLayout(left_layout)
        self.outer_layout.addLayout(self.right_layout)
        

        
        self.polygon_comboboxes = []
        self.add_polygon_combobox()

        self.slot_update_polygons(self.current_dataset.polygons,0)
        
        
        self.setLayout(self.outer_layout)
        
        
        self.resize(900, 700) 
        self.load_values_from_dataset()
        
        self.init_in_progress = False
        
        #at startup, display newest:
        self.slot_last_dataset()
コード例 #13
0
ファイル: test_display_pr2_try1.py プロジェクト: wklharry/hrl
    #rot = np.matrix([[1,0,0],[0,1,0],[0,0,1]])
    #[above] data location must hold xml training data to load. or get error!
    #[above] dataset id should be a unique name for files in subfolder data/

#----------------------
'''Number of points to  '''
NUMBER_OF_POINTS = 7000  #some large number #previously only 1000
SCALE = 1
IS_LABELED = True  #What happens if false? Assume = No ROI cropping.  Might get skipped altogether.  TODO:check.

displayOn = True
print getTime(), 'IMPORTS DONE'

###CHANGE THIS TO THE DIRECTORY WITH RESULTS FROM CODY:
###  change 'codyRobot' to 'dummyScanner' or code tries to find camera drivers, etc.
cfg = configuration.configuration(DATA_LOCATION, ROBOT)  #'dummyScanner'
pc = processor.processor(cfg)

pc.features_k_nearest_neighbors = None
'''
    @param z_above_floor Approximate height of hokuyo above the ground.  Asssumed
    to be fixed for now.  On Cody robot the camera and hokuyo were at same z-height.
'''


def create_default_scan_dataset(unique_id=DATASET_ID, z_above_floor=1.32):
    dataset = scan_dataset()
    dataset.table_plane_translation = np.matrix([0, 0, 0]).T
    # approximate height of hokuyo above the ground, assume it to be fixed for now.
    dataset.ground_plane_translation = np.matrix([0, 0, z_above_floor]).T
    dataset.ground_plane_rotation = ''  #expects a 3x3 numpy matrix
コード例 #14
0
ファイル: labeling_tool.py プロジェクト: wklharry/hrl
    def __init__(self, path, parent=None):

        self.init_in_progress = True

        self.path = path

        # load configs for taking scans, etc:
        self.config = configuration.configuration(path)
        #create scanner and processor when needed:
        self.scanner = False
        self.processor = False

        # load database:
        self.scans_database = scans_database.scans_database()
        self.scans_database.load(path, 'database.pkl')

        #get first dataset:
        self.current_dataset = self.scans_database.get_dataset(0)

        QtGui.QWidget.__init__(self, parent)
        self.setWindowTitle('labeling tool')

        left_layout = QtGui.QVBoxLayout()
        self.draw_widget = draw_widget(
            self.current_dataset.polygons,
            self.scans_database.get_path() + '/' +
            self.current_dataset.image_filename, self)

        title_layout = QtGui.QHBoxLayout()

        take_scan_button = QtGui.QPushButton('Scan')
        take_scan_button.setMaximumWidth(50)
        title_layout.addWidget(take_scan_button)
        self.connect(take_scan_button, QtCore.SIGNAL('clicked()'),
                     self.slot_take_scan)

        take_artag_image_button = QtGui.QPushButton('ARTag')
        take_artag_image_button.setMaximumWidth(50)
        title_layout.addWidget(take_artag_image_button)
        self.connect(take_artag_image_button, QtCore.SIGNAL('clicked()'),
                     self.slot_take_artag_image)

        button = QtGui.QPushButton('Import Img')
        title_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'),
                     self.slot_import_image)

        label = QtGui.QLabel("View: ")
        title_layout.addWidget(label)
        self.display_3d_button = QtGui.QPushButton('3D')
        self.display_3d_button.setMaximumWidth(40)
        title_layout.addWidget(self.display_3d_button)
        self.connect(self.display_3d_button, QtCore.SIGNAL('clicked()'),
                     self.slot_display_3d)

        combobox = QtGui.QComboBox()
        combobox.addItem("Height", QtCore.QVariant("height"))
        combobox.addItem("Intensities", QtCore.QVariant("intensities"))
        #combobox.addItem("objects", QtCore.QVariant("objects"))
        combobox.addItem("Labels", QtCore.QVariant("labels"))
        combobox.addItem("Classifier range", QtCore.QVariant("range"))
        combobox.addItem("Classifier color", QtCore.QVariant("color"))
        combobox.addItem("Classifier all", QtCore.QVariant("all"))
        combobox.addItem("Classifier all+post", QtCore.QVariant("all_post"))
        combobox.addItem("Baseline algo", QtCore.QVariant("baseline"))
        combobox.addItem("h", QtCore.QVariant("h"))
        combobox.addItem("s", QtCore.QVariant("s"))
        combobox.addItem("v", QtCore.QVariant("v"))
        self.connect(combobox, QtCore.SIGNAL('currentIndexChanged(int)'),
                     self.slot_update_display_3d_type)
        title_layout.addWidget(combobox)
        self.display_3d_type_combobox = combobox

        self.display_3d_spheres_button = QtGui.QPushButton('3D_Spheres')
        title_layout.addWidget(self.display_3d_spheres_button)
        self.connect(self.display_3d_spheres_button,
                     QtCore.SIGNAL('clicked()'), self.slot_display_3d_spheres)
        self.display_intensity_button = QtGui.QPushButton('Intensity')
        self.display_intensity_button.setMaximumWidth(50)
        title_layout.addWidget(self.display_intensity_button)
        self.connect(self.display_intensity_button, QtCore.SIGNAL('clicked()'),
                     self.slot_display_intensity)
        self.display_features_button = QtGui.QPushButton('Features')
        title_layout.addWidget(self.display_features_button)
        self.display_features_button.setMaximumWidth(50)
        self.connect(self.display_features_button, QtCore.SIGNAL('clicked()'),
                     self.slot_display_features)
        self.display_labels_button = QtGui.QPushButton('Labels')
        title_layout.addWidget(self.display_labels_button)
        self.display_labels_button.setMaximumWidth(50)
        self.connect(self.display_labels_button, QtCore.SIGNAL('clicked()'),
                     self.slot_display_labels)
        self.display_stats_button = QtGui.QPushButton('Stats')
        title_layout.addWidget(self.display_stats_button)
        self.display_stats_button.setMaximumWidth(50)
        self.connect(self.display_stats_button, QtCore.SIGNAL('clicked()'),
                     self.slot_display_stats)
        self.display_global_stats_button = QtGui.QPushButton('Global Stats')
        title_layout.addWidget(self.display_global_stats_button)
        self.display_global_stats_button.setMaximumWidth(50)
        self.connect(self.display_global_stats_button,
                     QtCore.SIGNAL('clicked()'),
                     self.slot_display_global_stats)

        self.line_edits = []

        self.add_line_edit('Title:', title_layout, 'title')

        first_dataset_button = QtGui.QPushButton('<<')
        first_dataset_button.setMaximumWidth(30)
        title_layout.addWidget(first_dataset_button)
        self.connect(first_dataset_button, QtCore.SIGNAL('clicked()'),
                     self.slot_first_dataset)
        prev_dataset_button = QtGui.QPushButton('<')
        prev_dataset_button.setMaximumWidth(30)
        title_layout.addWidget(prev_dataset_button)
        self.connect(prev_dataset_button, QtCore.SIGNAL('clicked()'),
                     self.slot_prev_dataset)
        next_dataset_button = QtGui.QPushButton('>')
        next_dataset_button.setMaximumWidth(30)
        title_layout.addWidget(next_dataset_button)
        self.connect(next_dataset_button, QtCore.SIGNAL('clicked()'),
                     self.slot_next_dataset)
        last_dataset_button = QtGui.QPushButton('>>')
        last_dataset_button.setMaximumWidth(30)
        title_layout.addWidget(last_dataset_button)
        self.connect(last_dataset_button, QtCore.SIGNAL('clicked()'),
                     self.slot_last_dataset)

        save_button = QtGui.QPushButton('Save')
        title_layout.addWidget(save_button)
        save_button.setMaximumWidth(50)
        self.connect(save_button, QtCore.SIGNAL('clicked()'), self.slot_save)

        delete_button = QtGui.QPushButton('Delete')
        title_layout.addWidget(delete_button)
        delete_button.setMaximumWidth(50)
        self.connect(delete_button, QtCore.SIGNAL('clicked()'),
                     self.slot_delete)

        self.connect(self.draw_widget, QtCore.SIGNAL('sigPolyChanged'),
                     self.slot_update_polygons)
        self.connect(self.draw_widget, QtCore.SIGNAL('sigPolyLabelChanged'),
                     self.slot_update_polygon_label)
        self.connect(self.draw_widget, QtCore.SIGNAL('sigDefineGroundPlane'),
                     self.slot_define_ground_plane)

        left_layout.addLayout(title_layout)

        #second row:
        row2_layout = QtGui.QHBoxLayout()
        left_layout.addLayout(row2_layout)

        label = QtGui.QLabel("Id:")
        row2_layout.addWidget(label)
        self.id_label = QtGui.QLabel("")
        row2_layout.addWidget(self.id_label)

        self.add_line_edit('Surface: ID:', row2_layout, 'surface_id')
        self.add_line_edit('Height', row2_layout, 'surface_height')

        label = QtGui.QLabel("Type: ")
        row2_layout.addWidget(label)
        combobox = QtGui.QComboBox()
        combobox.addItem("Table Office", QtCore.QVariant("table_office"))
        combobox.addItem("Table Dorm", QtCore.QVariant("table_dorm"))
        combobox.addItem("Table House", QtCore.QVariant("table_house"))
        combobox.addItem("Shelf Office", QtCore.QVariant("shelf_office"))
        combobox.addItem("Shelf Dorm", QtCore.QVariant("shelf_dorm"))
        combobox.addItem("Shelf House", QtCore.QVariant("shelf_house"))
        self.connect(combobox, QtCore.SIGNAL('currentIndexChanged(int)'),
                     self.slot_update_surface_type)
        row2_layout.addWidget(combobox)
        self.surface_type_combobox = combobox

        self.add_line_edit('Camera: Height:', row2_layout, 'camera_height')
        self.add_line_edit('Camera: Angle:', row2_layout, 'camera_angle')

        #####################################
        #thrid row:
        row3_layout = QtGui.QHBoxLayout()
        left_layout.addLayout(row3_layout)

        #checkboxes:
        button = QtGui.QPushButton("&gen'n'save features")
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'),
                     self.slot_generate_save_features)

        checkbox = QtGui.QCheckBox('&Training Set')
        row3_layout.addWidget(checkbox)
        self.connect(checkbox, QtCore.SIGNAL('stateChanged(int)'),
                     self.slot_update_training_set)
        self.checkbox_training_set = checkbox

        checkbox = QtGui.QCheckBox('Te&st Set')
        row3_layout.addWidget(checkbox)
        self.connect(checkbox, QtCore.SIGNAL('stateChanged(int)'),
                     self.slot_update_test_set)
        self.checkbox_test_set = checkbox

        checkbox = QtGui.QCheckBox('Labels, Groundp. checked')
        row3_layout.addWidget(checkbox)
        self.connect(checkbox, QtCore.SIGNAL('stateChanged(int)'),
                     self.slot_update_is_labeled)
        self.checkbox_is_labeled = checkbox

        button = QtGui.QPushButton("Train'n'save Classifiers (training set)")
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'),
                     self.slot_train_and_save_Classifiers)

        button = QtGui.QPushButton('Test Classifiers (on current)')
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'),
                     self.slot_test_Classifiers)

        button = QtGui.QPushButton('Test Classifiers (on testset)')
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'),
                     self.slot_test_Classifiers_on_testset)

        button = QtGui.QPushButton('Load Classifiers')
        row3_layout.addWidget(button)
        self.connect(button, QtCore.SIGNAL('clicked()'),
                     self.slot_load_Classifiers)

        #        button = QtGui.QPushButton('Save Classifier')
        #        row3_layout.addWidget(button)
        #        self.connect(button, QtCore.SIGNAL('clicked()'), self.slot_save_Classifier )

        #####################################

        left_layout.addWidget(self.draw_widget)

        self.right_layout = QtGui.QVBoxLayout()
        self.right_layout.setAlignment(QtCore.Qt.AlignTop)

        self.outer_layout = QtGui.QHBoxLayout()
        self.outer_layout.addLayout(left_layout)
        self.outer_layout.addLayout(self.right_layout)

        self.polygon_comboboxes = []
        self.add_polygon_combobox()

        self.slot_update_polygons(self.current_dataset.polygons, 0)

        self.setLayout(self.outer_layout)

        self.resize(900, 700)
        self.load_values_from_dataset()

        self.init_in_progress = False

        #at startup, display newest:
        self.slot_last_dataset()
コード例 #15
0
    #[above] data location must hold xml training data to load. or get error!
    #[above] dataset id should be a unique name for files in subfolder data/

#----------------------
'''Number of points to  '''
NUMBER_OF_POINTS = 7000#some large number #previously only 1000
SCALE = 1
IS_LABELED = True #What happens if false? Assume = No ROI cropping.  Might get skipped altogether.  TODO:check.


displayOn = True 
print getTime(), 'IMPORTS DONE'

###CHANGE THIS TO THE DIRECTORY WITH RESULTS FROM CODY:
###  change 'codyRobot' to 'dummyScanner' or code tries to find camera drivers, etc.
cfg = configuration.configuration(DATA_LOCATION, ROBOT) #'dummyScanner'
pc = processor.processor(cfg)

pc.features_k_nearest_neighbors = None

'''
    @param z_above_floor Approximate height of hokuyo above the ground.  Asssumed
    to be fixed for now.  On Cody robot the camera and hokuyo were at same z-height.
'''
def create_default_scan_dataset(unique_id = DATASET_ID, z_above_floor=1.32):
    dataset = scan_dataset()
    dataset.table_plane_translation = np.matrix([0,0,0]).T
    # approximate height of hokuyo above the ground, assume it to be fixed for now.
    dataset.ground_plane_translation = np.matrix([0,0,z_above_floor]).T 
    dataset.ground_plane_rotation = ''  #expects a 3x3 numpy matrix
    #pc.scan_dataset.is_test_set = True