(self, pair_idx, resolution, rng)
| 34 | return f'{len(self)} pairs' |
| 35 | |
| 36 | def _get_views(self, pair_idx, resolution, rng): |
| 37 | scene, seq, cam1, im1, cam2, im2 = self.pairs[pair_idx] |
| 38 | seq_path = osp.join('TRAIN', scene.decode('ascii'), f'{seq:04d}') |
| 39 | |
| 40 | views = [] |
| 41 | |
| 42 | mask_bg = (self.mask_bg == True) or (self.mask_bg == 'rand' and rng.choice(2)) |
| 43 | |
| 44 | CAM = {b'l':'left', b'r':'right'} |
| 45 | for cam, idx in [(CAM[cam1], im1), (CAM[cam2], im2)]: |
| 46 | num = f"{idx:04n}" |
| 47 | img = num+"_clean.jpg" if rng.choice(2) else num+"_final.jpg" |
| 48 | image = imread_cv2(osp.join(self.ROOT, seq_path, cam, img)) |
| 49 | depthmap = imread_cv2(osp.join(self.ROOT, seq_path, cam, num+".exr")) |
| 50 | camera_params = np.load(osp.join(self.ROOT, seq_path, cam, num+".npz")) |
| 51 | |
| 52 | intrinsics = camera_params['intrinsics'] |
| 53 | camera_pose = camera_params['cam2world'] |
| 54 | |
| 55 | if mask_bg: |
| 56 | depthmap[depthmap > 200] = 0 |
| 57 | |
| 58 | image, depthmap, intrinsics = self._crop_resize_if_necessary(image, depthmap, intrinsics, resolution, rng, info=(seq_path,cam,img)) |
| 59 | |
| 60 | views.append(dict( |
| 61 | img = image, |
| 62 | depthmap = depthmap, |
| 63 | camera_pose = camera_pose, # cam2world |
| 64 | camera_intrinsics = intrinsics, |
| 65 | dataset = 'StaticThings3D', |
| 66 | label = seq_path, |
| 67 | instance = cam+'_'+img)) |
| 68 | |
| 69 | return views |
| 70 | |
| 71 | |
| 72 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected