def preprocess_windows(windows0, walls): ''' both windows0 ad walls are standard: [xc, yc, zc, x_size, y_size, z_size, yaw] ''' if DEBUG and False: print('input') show_all([windows0, walls]) #Bbox3D.draw_bboxes(walls, 'Z', False) #Bbox3D.draw_bboxes(windows0, 'Z', False) #print(f'windows0: \n{windows0}') if len(windows0) == 0: return windows0 windows1 = Bbox3D.define_walls_direction(windows0, 'Z', yx_zb=False) #print(f'windows1: \n{windows0}') win_bad_ids, wall_ids_for_bad_win = find_wall_ids_for_windows( windows1, walls) windows_bad = windows1[win_bad_ids].reshape(-1, 7) walls_bw = walls[wall_ids_for_bad_win].reshape(-1, 7) windows_corrected = correct_bad_windows(windows_bad, walls_bw) windows1[win_bad_ids] = windows_corrected if DEBUG and False: print('out') show_all([windows1, walls]) return windows1
def preprocess_walls(wall_bboxes): ''' The framework to generate wall ground truth from SUNCG 1) Make y-dim as thickness, x_size > y_size, yaw in (-pi/2, pi/2] 2) If a final wall is originally splitted as pieces in SUNCG, merge them as one 3) If a wall in SUNCG actually contains several finally walls, crop it 4) Clean repeated walls ''' show_pro = False if show_pro: print('original') show_walls_offsetz(wall_bboxes) #Bbox3D.draw_bboxes_mesh(wall_bboxes, 'Z', False) #Bbox3D.draw_bboxes(wall_bboxes, 'Z', False) if wall_bboxes.shape[0] == 0: return wall_bboxes wall_bboxes = Bbox3D.define_walls_direction(wall_bboxes, 'Z', yx_zb=False, check_thickness=True) wall_bboxes = merge_pieces_of_same_walls_alongY(wall_bboxes) if show_pro: print('merge_pieces_of_same_walls_alongY') show_walls_offsetz(wall_bboxes) wall_bboxes = merge_pieces_of_same_walls_alongX(wall_bboxes) if show_pro: print('merge_pieces_of_same_walls_alongX') show_walls_offsetz(wall_bboxes) wall_bboxes = crop_walls(wall_bboxes) if show_pro: print('crop_walls') show_walls_offsetz(wall_bboxes) wall_bboxes = merge_pieces_of_same_walls_alongY(wall_bboxes) if show_pro: print( 'merge_pieces_of_same_walls_alongY again after crop_walls to solve some special case: Originally, a wall is broken by no intersection like 0058113bdc8bee5f387bb5ad316d7b28' ) show_walls_offsetz(wall_bboxes) wall_bboxes = find_close_walls(wall_bboxes) if show_pro: print('clean_close_walls') show_walls_offsetz(wall_bboxes) #intersections = Bbox3D.all_intersections_by_cenline(wall_bboxes, not_on_corners=True, show_res=True) #mask =( wall_bboxes[:,0] < 45) * (wall_bboxes[:,0] > 43) #wall_bboxes_ = wall_bboxes[mask] if DEBUG and 0: show_walls_offsetz(wall_bboxes) return wall_bboxes