Save as the format used by LLFF. LLFF processes the outputs of COLMAP, and we will only output a subset of it. See: https://github.com/Fyusion/LLFF#using-your-own-poses-without-running-colmap Each scene in the dataset contains - images/ - xxxx.
(
self,
output_dirs: T.List[str],
start_idx: int = 0,
exist_ok: bool = True,
overwrite: bool = False,
hit_only: bool = False,
)
| 3067 | return output_dirs |
| 3068 | |
| 3069 | def save_as_llff( |
| 3070 | self, |
| 3071 | output_dirs: T.List[str], |
| 3072 | start_idx: int = 0, |
| 3073 | exist_ok: bool = True, |
| 3074 | overwrite: bool = False, |
| 3075 | hit_only: bool = False, |
| 3076 | ) -> T.List[str]: |
| 3077 | """ |
| 3078 | Save as the format used by LLFF. |
| 3079 | |
| 3080 | LLFF processes the outputs of COLMAP, and we will only output a subset of it. |
| 3081 | |
| 3082 | See: https://github.com/Fyusion/LLFF#using-your-own-poses-without-running-colmap |
| 3083 | |
| 3084 | Each scene in the dataset contains |
| 3085 | - images/ |
| 3086 | - xxxx.jpg (total of n (h, w, 3) images) |
| 3087 | - images_2/ |
| 3088 | - xxxx.png (total of n (h, w, 3/4) images |
| 3089 | - poses_bounds.npy: (n, 17) |
| 3090 | the first dimension is ordered by sorted filenames of files in images |
| 3091 | poses[:, 0:12]: vec(H_c2b) (x down, y right, z us) |
| 3092 | poses[:, 12:15]: hwf in pixel |
| 3093 | poses[:, 15:17]: z_min z_max in the camera coordinate |
| 3094 | |
| 3095 | We can get the camera poses in opengl coordinate, intrinsics (hwf), z_c range by |
| 3096 | poses = poses_arr[:, :-2].reshape([-1, 3, 5]).transpose([1, 2, 0]) # (3, 5, n) |
| 3097 | bds = poses_arr[:, -2:].transpose([1, 0]) # (2, n) z_near, z_far |
| 3098 | |
| 3099 | # Convert R matrix from the form [down right back] to [right up back] |
| 3100 | poses = np.concatenate( |
| 3101 | [poses[:, 1:2, :], -poses[:, 0:1, :], poses[:, 2:, :]], 1) # (3, 5, n) |
| 3102 | |
| 3103 | poses[:3, :4] is now H_c2w in the coordinate of x to right, y to up, z to us |
| 3104 | poses[:3, 4] is now hwf in pixel |
| 3105 | |
| 3106 | intrinsic_matrix = np.array([[f, 0, w/2], |
| 3107 | [0, f, h/2], |
| 3108 | [0, 0, 1]]).astype(np.float32) |
| 3109 | |
| 3110 | Args: |
| 3111 | output_dirs: |
| 3112 | (b,) output folders for each b |
| 3113 | |
| 3114 | Returns: |
| 3115 | list of output_dir, one per each b |
| 3116 | """ |
| 3117 | |
| 3118 | assert len(output_dirs) == self.rgb.size(0) |
| 3119 | for output_dir in output_dirs: |
| 3120 | if overwrite: |
| 3121 | try: |
| 3122 | shutil.rmtree(output_dir) |
| 3123 | except: |
| 3124 | pass |
| 3125 | if os.path.exists(output_dir) and not exist_ok: |
| 3126 | raise RuntimeError |