sys.path.append(os.path.join(os.getcwd())) # HACK add the root folder from lib.config import CONF from lib.projection import ProjectionHelper SCANNET_LIST = CONF.SCANNETV2_LIST SCANNET_DATA = CONF.PATH.SCANNET_DATA SCANNET_FRAME_ROOT = CONF.SCANNET_FRAMES SCANNET_FRAME_PATH = os.path.join(SCANNET_FRAME_ROOT, "{}") # name of the file ENET_FEATURE_PATH = CONF.ENET_FEATURES_PATH ENET_FEATURE_DATABASE = CONF.MULTIVIEW # projection INTRINSICS = [[37.01983, 0, 20, 0],[0, 38.52470, 15.5, 0],[0, 0, 1, 0],[0, 0, 0, 1]] PROJECTOR = ProjectionHelper(INTRINSICS, 0.1, 4.0, [41, 32], 0.05) def get_scene_list(): with open(SCANNET_LIST, 'r') as f: return sorted(list(set(f.read().splitlines()))) def to_tensor(arr): return torch.Tensor(arr).cuda() def resize_crop_image(image, new_image_dims): image_dims = [image.shape[1], image.shape[0]] if image_dims == new_image_dims: return image resize_width = int(math.floor(new_image_dims[1] * float(image_dims[0]) / float(image_dims[1]))) image = transforms.Resize([new_image_dims[1], resize_width], interpolation=Image.NEAREST)(Image.fromarray(image)) image = transforms.CenterCrop([new_image_dims[1], new_image_dims[0]])(image)
from lib.projection import ProjectionHelper # data path SCANNET_LIST = CONF.SCANNETV2_LIST SCANNET_DATA = CONF.PREP_SCANS PROJECTION_ROOT = CONF.PROJECTION PROJECTION_PATH = os.path.join(PROJECTION_ROOT, "{}_{}.npy") # scene_id, mode # scannet data # NOTE: read only! SCANNET_FRAME_ROOT = CONF.SCANNET_FRAMES SCANNET_FRAME_PATH = os.path.join(SCANNET_FRAME_ROOT, "{}") # name of the file # projection INTRINSICS = [[37.01983, 0, 20, 0],[0, 38.52470, 15.5, 0],[0, 0, 1, 0],[0, 0, 0, 1]] PROJECTOR = ProjectionHelper(INTRINSICS, 0.1, 4.0, [41, 32], 0.05) def get_scene_list(): with open(SCANNET_LIST, 'r') as f: scene_list = sorted(list(set(f.read().splitlines()))) return scene_list def load_scene(scene_list): scene_data = {} for scene_id in scene_list: scene_data[scene_id] = np.load(os.path.join(SCANNET_DATA, scene_id)+".npy")[:, :3] return scene_data def resize_crop_image(image, new_image_dims):