mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-22 15:45:39 +08:00
Add more controls for orienting poses (#800)
This commit is contained in:
1 parent
52e2c61e6b
commit
951d972716
3 files changed
+32
-14
No files matched your search
@@ -53,8 +53,12 @@ class NerfstudioDataParserConfig(DataParserConfig):
|
||||
"""How much to downscale images. If not set, images are chosen such that the max dimension is <1600px."""
|
||||
scene_scale: float = 1.0
|
||||
"""How much to scale the region of interest by."""
|
||||
orientation_method: Literal["pca", "up"] = "up"
|
||||
orientation_method: Literal["pca", "up", "none"] = "up"
|
||||
"""The method to use for orientation."""
|
||||
center_poses: bool = True
|
||||
"""Whether to center the poses."""
|
||||
auto_scale_poses: bool = True
|
||||
"""Whether to automatically scale the poses to fit in +/- 1 bounding box."""
|
||||
train_split_percentage: float = 0.9
|
||||
"""The percent of images to use for training. The remaining images are for eval."""
|
||||
|
||||
@@ -112,10 +116,15 @@ class Nerfstudio(DataParser):
|
||||
raise ValueError(f"Unknown dataparser split {split}")
|
||||
|
||||
poses = torch.from_numpy(np.array(poses).astype(np.float32))
|
||||
poses = camera_utils.auto_orient_poses(poses, method=self.config.orientation_method)
|
||||
poses = camera_utils.auto_orient_and_center_poses(
|
||||
poses, method=self.config.orientation_method, center_poses=self.config.center_poses
|
||||
)
|
||||
|
||||
# Scale poses
|
||||
scale_factor = 1.0 / torch.max(torch.abs(poses[:, :3, 3]))
|
||||
scale_factor = 1.0
|
||||
if self.config.auto_scale_poses:
|
||||
scale_factor /= torch.max(torch.abs(poses[:, :3, 3]))
|
||||
|
||||
poses[:, :3, 3] *= scale_factor * self.config.scale_factor
|
||||
|
||||
# Choose image_filenames and poses based on split, but after auto orient and scaling the poses.
|
||||
|
||||
@@ -105,9 +105,9 @@ class Record3D(DataParser):
|
||||
# convert to Tensors
|
||||
poses = torch.from_numpy(poses[:, :3, :4])
|
||||
|
||||
poses = camera_utils.auto_orient_poses(pose_utils.to4x4(poses), method=self.config.orientation_method)[
|
||||
:, :3, :4
|
||||
]
|
||||
poses = camera_utils.auto_orient_and_center_poses(
|
||||
pose_utils.to4x4(poses), method=self.config.orientation_method
|
||||
)[:, :3, :4]
|
||||
|
||||
# Centering poses
|
||||
poses[:, :3, 3] = poses[:, :3, 3] - torch.mean(poses[:, :3, 3], dim=0)
|
||||
|
||||
Reference in new issue
Block a user