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
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
def start_new_polygon(self): if False == self.polygons[self.current_polygon_index].is_empty(): # if self.current_polygon_index == len(self.polygons) - 1: self.polygons.append( label_object.label_object()) #last one, append new self.current_polygon_index = len(self.polygons) - 1 print "new poly index: ", self.current_polygon_index
def define_ROI_polygons(width_min, width_max, height_min, height_max): p = label_object() p.set_label('surface') p.add_point((width_min, height_min)) p.add_point((width_min, height_max)) p.add_point((width_max, height_max)) p.add_point((width_max, height_min)) table_surface = p #A polygon shape (rectangle) defining most generous guess of table surface. print 'surface', p.get_points() p = label_object() p.set_label('edge_down') p.add_point((width_min, height_min)) p.add_point((width_min, height_max)) p.add_point((width_max, height_max)) p.add_point((width_max, height_min)) p.add_point((width_min, height_min)) list_of_edges = (p, ) # [Above] Any number of polygons which define surface border. More can be added. print 'edge', p.get_points() return table_surface, list_of_edges
def define_ROI_polygons(width_min, width_max, height_min, height_max): p = label_object() p.set_label('surface') p.add_point((width_min,height_min)) p.add_point((width_min,height_max)) p.add_point((width_max,height_max)) p.add_point((width_max,height_min)) table_surface = p #A polygon shape (rectangle) defining most generous guess of table surface. print 'surface',p.get_points() p = label_object() p.set_label('edge_down') p.add_point((width_min,height_min)) p.add_point((width_min,height_max)) p.add_point((width_max,height_max)) p.add_point((width_max,height_min)) p.add_point((width_min,height_min)) list_of_edges = (p,) # [Above] Any number of polygons which define surface border. More can be added. print 'edge',p.get_points() return table_surface, list_of_edges
def __init__(self): ''' Constructor ''' self.dict = {} self.dict['title'] = '' self.dict['id'] = '' self.dict['polygons'] = [label_object.label_object()] self.dict['scan_filename'] = '' self.dict['image_filename'] = '' self.dict['image_artag_filename'] = '' self.dict['surface_id'] = '' self.dict['surface_height'] = '' self.dict['camera_height'] = '' self.dict['camera_angle'] = '' self.dict['surface_type'] = '' self.dict['ground_plane_normal'] = '' self.dict['ground_plane_three_points'] = '' self.dict['is_training_set'] = False self.dict['is_test_set'] = False self.dict['is_labeled'] = False
def start_new_polygon(self): if False == self.polygons[self.current_polygon_index].is_empty(): # if self.current_polygon_index == len(self.polygons) - 1: self.polygons.append(label_object.label_object()) #last one, append new self.current_polygon_index = len(self.polygons) - 1 print "new poly index: ", self.current_polygon_index
* pc.image_labels * pc.img_mapped * pc.img_mapped_polygons * testresults #Not sure what this is? * data_idx #indexes taken from pts3d_bound ONLY where label is nonzero * data #3d values of pts3d_bound where label is nonzero... # However as a list so 3x longer. * scan_indices - an artifact from the hokuyo. Original acquired line order? ''' if False: ####### Placement routine. object_height = 0.1 #SCALE = 1 resolution = [.01 * SCALE, .01 * SCALE] #sets resolution of occupancy grid print 'NOTE: Resolution is ', 100 * resolution[0], 'cm' ### polygon = label_object() polygon.add_point([0, 0]) polygon.add_point([0, 5 * SCALE]) polygon.add_point([10 * SCALE, 5 * SCALE]) polygon.add_point([10 * SCALE, 0]) ###object_height = 0.1 print 'creating placement object' pl = Placement( pc, resolution) ###REPLACE WITH MY OWN CLASS DEFINITION WITH FUNCTIONs if displayOn: placement_point = pl.test_placement(polygon, object_height) else: placement_point = pl.find_placement( polygon, object_height) #Add param True to get debug popups
* pc.image_labels * pc.img_mapped * pc.img_mapped_polygons * testresults #Not sure what this is? * data_idx #indexes taken from pts3d_bound ONLY where label is nonzero * data #3d values of pts3d_bound where label is nonzero... # However as a list so 3x longer. * scan_indices - an artifact from the hokuyo. Original acquired line order? ''' if False: ####### Placement routine. object_height = 0.1 #SCALE = 1 resolution = [.01*SCALE, .01*SCALE] #sets resolution of occupancy grid print 'NOTE: Resolution is ',100*resolution[0], 'cm' ### polygon = label_object() polygon.add_point([0,0]) polygon.add_point([0,5*SCALE]) polygon.add_point([10*SCALE,5*SCALE]) polygon.add_point([10*SCALE,0]) ###object_height = 0.1 print 'creating placement object' pl = Placement(pc, resolution) ###REPLACE WITH MY OWN CLASS DEFINITION WITH FUNCTIONs if displayOn: placement_point = pl.test_placement(polygon, object_height) else: placement_point = pl.find_placement(polygon, object_height)#Add param True to get debug popups placement_point -= pc.scan_dataset.ground_plane_translation
def convert_ROS_polygon_to_polygon(ROS_polygon): polygon = label_object() for point in ROS_polygon.points: polygon.add_point((point.x,point.y)) return polygon