MCPcopy Index your code
hub / github.com/DNA-Rendering/DNA-Rendering / __init__

Method __init__

scripts/3DGS/cameras.py:18–64  ·  view source on GitHub ↗
(self, colmap_id, R, T, FoVx, FoVy, image, gt_alpha_mask,
                 image_name, uid,
                 K=None, use_K=False,
                 trans=np.array([0.0, 0.0, 0.0]), scale=1.0, data_device = "cuda"
                 )

Source from the content-addressed store, hash-verified

16
17class Camera(nn.Module):
18 def __init__(self, colmap_id, R, T, FoVx, FoVy, image, gt_alpha_mask,
19 image_name, uid,
20 K=None, use_K=False,
21 trans=np.array([0.0, 0.0, 0.0]), scale=1.0, data_device = "cuda"
22 ):
23 super(Camera, self).__init__()
24
25 self.uid = uid
26 self.colmap_id = colmap_id
27 self.R = R
28 self.T = T
29 self.FoVx = FoVx
30 self.FoVy = FoVy
31 self.K = K
32 self.use_K = use_K
33 self.image_name = image_name
34
35 try:
36 self.data_device = torch.device(data_device)
37 except Exception as e:
38 print(e)
39 print(f"[Warning] Custom device {data_device} failed, fallback to default cuda device" )
40 self.data_device = torch.device("cuda")
41
42 self.original_image = image.clamp(0.0, 1.0).to(self.data_device)
43 self.image_width = self.original_image.shape[2]
44 self.image_height = self.original_image.shape[1]
45
46 if gt_alpha_mask is not None:
47 self.original_image *= gt_alpha_mask.to(self.data_device)
48 else:
49 self.original_image *= torch.ones((1, self.image_height, self.image_width), device=self.data_device)
50
51 self.zfar = 100.0
52 self.znear = 0.01
53
54 self.trans = trans
55 self.scale = scale
56
57 self.world_view_transform = torch.tensor(getWorld2View2(R, T, trans, scale)).transpose(0, 1).cuda()
58 if not self.use_K:
59 self.projection_matrix = getProjectionMatrix(znear=self.znear, zfar=self.zfar, fovX=self.FoVx, fovY=self.FoVy).transpose(0,1).cuda()
60 else:
61 self.projection_matrix = getProjectionMatrix2(self.znear, self.zfar, self.K, self.image_width, self.image_height).transpose(0,1).cuda()
62
63 self.full_proj_transform = (self.world_view_transform.unsqueeze(0).bmm(self.projection_matrix.unsqueeze(0))).squeeze(0)
64 self.camera_center = self.world_view_transform.inverse()[3, :3]
65
66class MiniCam:
67 def __init__(self, width, height, fovy, fovx, znear, zfar, world_view_transform, full_proj_transform):

Callers

nothing calls this directly

Calls 3

getWorld2View2Function · 0.90
getProjectionMatrixFunction · 0.90
getProjectionMatrix2Function · 0.90

Tested by

no test coverage detected