| 183 | return poses[:,:3,:].reshape(poses.shape[0],12) |
| 184 | |
| 185 | class SevenScenes(data.Dataset): |
| 186 | def __init__(self, scene, data_path, train, transform=None, |
| 187 | target_transform=None, mode=0, seed=7, |
| 188 | df=1., trainskip=1, testskip=1, hwf=[480,640,585.], |
| 189 | ret_idx=False, fix_idx=False, ret_hist=False, hist_bin=10): |
| 190 | """ |
| 191 | :param scene: scene name ['chess', 'pumpkin', ...] |
| 192 | :param data_path: root 7scenes data directory. |
| 193 | Usually '../data/deepslam_data/7Scenes' |
| 194 | :param train: if True, return the training images. If False, returns the |
| 195 | testing images |
| 196 | :param transform: transform to apply to the images |
| 197 | :param target_transform: transform to apply to the poses |
| 198 | :param mode: (Obsolete) 0: just color image, 1: color image in NeRF 0-1 and resized. |
| 199 | :param df: downscale factor |
| 200 | :param trainskip: due to 7scenes are so big, now can use less training sets # of trainset = 1/trainskip |
| 201 | :param testskip: skip part of testset, # of testset = 1/testskip |
| 202 | :param hwf: H,W,Focal from COLMAP |
| 203 | :param ret_idx: bool, currently only used by NeRF-W |
| 204 | """ |
| 205 | |
| 206 | self.transform = transform |
| 207 | self.target_transform = target_transform |
| 208 | self.df = df |
| 209 | |
| 210 | self.H, self.W, self.focal = hwf |
| 211 | self.H = int(self.H) |
| 212 | self.W = int(self.W) |
| 213 | np.random.seed(seed) |
| 214 | |
| 215 | self.train = train |
| 216 | self.ret_idx = ret_idx |
| 217 | self.fix_idx = fix_idx |
| 218 | self.ret_hist = ret_hist |
| 219 | self.hist_bin = hist_bin # histogram bin size |
| 220 | |
| 221 | # directories |
| 222 | base_dir = osp.join(osp.expanduser(data_path), scene) # '../data/deepslam_data/7Scenes' |
| 223 | data_dir = osp.join('..', 'data', '7Scenes', scene) # '../data/7Scenes/chess' |
| 224 | world_setup_fn = data_dir + '/world_setup.json' |
| 225 | |
| 226 | # read json file |
| 227 | with open(world_setup_fn, 'r') as myfile: |
| 228 | data=myfile.read() |
| 229 | |
| 230 | # parse json file |
| 231 | obj = json.loads(data) |
| 232 | self.near = obj['near'] |
| 233 | self.far = obj['far'] |
| 234 | self.pose_scale = obj['pose_scale'] |
| 235 | self.pose_scale2 = obj['pose_scale2'] |
| 236 | self.move_all_cam_vec = obj['move_all_cam_vec'] |
| 237 | |
| 238 | # decide which sequences to use |
| 239 | if train: |
| 240 | split_file = osp.join(base_dir, 'TrainSplit.txt') |
| 241 | else: |
| 242 | split_file = osp.join(base_dir, 'TestSplit.txt') |
no outgoing calls
no test coverage detected