nerfstudio icon indicating copy to clipboard operation
nerfstudio copied to clipboard

colmap point cloud transformation in colmap_dataparser.py

Open SeanGuo063 opened this issue 1 year ago • 3 comments

Current colmap point cloud tranformation in ColmapDataParser is:

def _load_3D_points(self, colmap_path: Path, transform_matrix: torch.Tensor, scale_factor: float): if (colmap_path / "points3D.bin").exists(): colmap_points = colmap_utils.read_points3D_binary(colmap_path / "points3D.bin") elif (colmap_path / "points3D.txt").exists(): colmap_points = colmap_utils.read_points3D_text(colmap_path / "points3D.txt") else: raise ValueError(f"Could not find points3D.txt or points3D.bin in {colmap_path}") points3D = torch.from_numpy(np.array([p.xyz for p in colmap_points.values()], dtype=np.float32)) points3D = ( torch.cat( ( points3D, torch.ones_like(points3D[..., :1]), ), -1, ) @ transform_matrix.T ) points3D *= scale_factor

However, the world coordinate system of nerfstuido is not the same with the world cooridnate system of colmap. The difference is caused by the method to convert the colmap pose to nerfstudio pose in self._get_all_images_and_cameras() in ColmapDataParser. [x, y, z] of 3D point in world cooridnate system of nerfstudio corresponds to [y, x, -z] of the colmap. Please correct me if it is not the cause.

SeanGuo063 avatar Dec 16 '23 07:12 SeanGuo063

I have almost exactly the same question, but haven't made any progress to date on trying to align the results. Have you had any success? If so, can you share?

ebbeowulf avatar Jan 03 '24 20:01 ebbeowulf

Same question.

yoavalon avatar Jan 08 '24 08:01 yoavalon

My current solution is to change [x, y, z] to [y, x, -z] right after reading the point cloud from colmap reconstruction

SeanGuo063 avatar Jan 09 '24 12:01 SeanGuo063