def switch_mapping(segmap, source_map, destination_map): # This assumes label names in different mappings are the same. # This function is mainly useful to map from the old class mapping to the now default NYU mapping. source_id_label_map, source_label_id_map = LabelIdMapping.read_csv_mapping(source_map) destination_id_label_map, destination_label_id_map = LabelIdMapping.read_csv_mapping(destination_map) new_segmap = np.zeros_like(segmap) unq = np.unique(segmap) for id in unq: label_name = source_id_label_map[id] if label_name in destination_label_id_map: destination_id = destination_label_id_map[source_id_label_map[id]] new_segmap[segmap == id] = destination_id return new_segmap
def __init__(self, config: Config): LoaderInterface.__init__(self, config) self.mapping_file = Utility.resolve_path( self.config.get_string( "mapping_file", os.path.join("resources", "front_3D", "3D_front_mapping.csv"))) if not os.path.exists(self.mapping_file): raise Exception("The mapping file could not be found: {}".format( self.mapping_file)) _, self.mapping = LabelIdMapping.read_csv_mapping(self.mapping_file)
def __init__(self, config: Config): LoaderInterface.__init__(self, config) self.json_path = Utility.resolve_path( self.config.get_string("json_path")) self.future_model_path = Utility.resolve_path( self.config.get_string("3D_future_model_path")) self.mapping_file = Utility.resolve_path( self.config.get_string( "mapping_file", os.path.join("resources", "front_3D", "3D_front_mapping.csv"))) if not os.path.exists(self.mapping_file): raise Exception("The mapping file could not be found: {}".format( self.mapping_file)) _, self.mapping = LabelIdMapping.read_csv_mapping(self.mapping_file) # a list of all newly created objects self.created_objects = []