4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 10:34:29 +08:00

[Fix] convert camera_idx to tensor (#2890)

convert camera_idx to tensor
This commit is contained in:
Tobias Fischer 2024-02-09 16:53:34 +01:00 committed by GitHub
parent 1d070f5625
commit efa91e5df7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -157,7 +157,7 @@ class CameraOptimizer(nn.Module):
assert camera.metadata is not None, "Must provide id of camera in its metadata"
assert "cam_idx" in camera.metadata, "Must provide id of camera in its metadata"
camera_idx = camera.metadata["cam_idx"]
adj = self([camera_idx]) # type: ignore
adj = self(torch.tensor([camera_idx], dtype=torch.long, device=camera.device)) # type: ignore
adj = torch.cat([adj, torch.Tensor([0, 0, 0, 1])[None, None].to(adj)], dim=1)
camera.camera_to_worlds = torch.bmm(camera.camera_to_worlds, adj)