MCPcopy Index your code
hub / github.com/apple/ml-pointersect / _set_manual

Method _set_manual

pointersect/inference/structures.py:4055–4126  ·  view source on GitHub ↗

Manually assign camera eye: list of (3,) where the cameras are (before global transform) up: None (assume to be (0,1,0)), (1,3) used for all cameras, or list of (3,) look_at: None (assume to be (0,0,0)), (1, 3) used for all cameras, or list of (3,)

(self)

Source from the content-addressed store, hash-verified

4053 self.cam_poses.append(poses)
4054
4055 def _set_manual(self):
4056 """
4057 Manually assign camera
4058 eye: list of (3,) where the cameras are (before global transform)
4059 up: None (assume to be (0,1,0)), (1,3) used for all cameras, or list of (3,)
4060 look_at: None (assume to be (0,0,0)), (1, 3) used for all cameras, or list of (3,)
4061 t_c2w: (3,) or None
4062 y_c2w: (3,) or None
4063 z_c2w: (3,) or None
4064 """
4065 assert 'eye' in self.params
4066 eyes = self.params['eye']
4067 eyes = [[float(i) for i in eye.split(' ')] for eye in eyes]
4068 eyes = torch.tensor(eyes).float().reshape(-1, 3) # (q, 3)
4069 assert self.n_imgs == eyes.size(0)
4070
4071 ups = self.params.get('up', None)
4072 if ups is None:
4073 ups = [0, 1., 0]
4074 else:
4075 ups = [[float(i) for i in x.split(' ')] for x in ups]
4076 ups = torch.tensor(ups).float().reshape(-1, 3) # (q, 3)
4077 if ups.size(0) == 1:
4078 ups = ups.expand_as(eyes) # (q, 3)
4079
4080 look_ats = self.params.get('look_at', None)
4081 if look_ats is None:
4082 look_ats = [0, 0., 0]
4083 else:
4084 look_ats = [[float(i) for i in x.split(' ')] for x in look_ats]
4085 look_ats = torch.tensor(look_ats).float().reshape(-1, 3) # (q, 3)
4086 if look_ats.size(0) == 1:
4087 look_ats = look_ats.expand_as(eyes) # (q, 3)
4088
4089 t_c2w = self.params.get('t_c2w', None)
4090 if t_c2w is None:
4091 t_c2w = torch.zeros(3) # (3,)
4092 else:
4093 t_c2w = [float(i) for i in t_c2w.split(' ')]
4094 t_c2w = torch.tensor(t_c2w).float()
4095 y_c2w = self.params.get('y_c2w', None)
4096 if y_c2w is None:
4097 y_c2w = torch.tensor([0, 1, 0]).float() # (3,)
4098 else:
4099 y_c2w = [float(i) for i in y_c2w.split(' ')]
4100 y_c2w = torch.tensor(y_c2w).float()
4101 z_c2w = self.params.get('z_c2w', None)
4102 if z_c2w is None:
4103 z_c2w = torch.tensor([0, 0, 1]).float() # (3,)
4104 else:
4105 z_c2w = [float(i) for i in z_c2w.split(' ')]
4106 z_c2w = torch.tensor(z_c2w).float()
4107 R_c2w = rigid_motion.construct_coord_frame(
4108 z=z_c2w,
4109 y=y_c2w,
4110 )
4111 H_c2w_global = torch.zeros(4, 4)
4112 H_c2w_global[:3, :3] = R_c2w

Callers 1

__init__Method · 0.95

Calls 4

splitMethod · 0.80
sizeMethod · 0.80
getMethod · 0.80
reshapeMethod · 0.45

Tested by

no test coverage detected