MCPcopy Create free account
hub / github.com/apple/ml-pointersect / _set_polar_grid

Method _set_polar_grid

pointersect/inference/structures.py:4013–4053  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4011 self.cam_poses.append(poses)
4012
4013 def _set_polar_grid(self):
4014 # both input and target are around the same circle path
4015 # sample num_theta points from [0,2*pi]
4016 # sample num_phi points from [0,pi], including two polars (0,pi)
4017 # assume sample theta and phi contain same number of angles on circle, 2*(num_phi-1) = num_theta
4018 # total point: num_theta* (num_phi-2) +2 = 2*num_phi^2 -6*num_phi +6
4019 # to make total point> self.n_target_imgs, num_phi >= (sqrt(2*self.n_imgs-3)+3)/2
4020 # common choice: self.n_target_imgs = 6, 14, 26, 42, ...
4021 # corresponding to num_phi = 3, 4, 5, 6,....
4022 assert 'min_r' in self.params
4023 assert 'max_r' in self.params
4024 max_r = self.params['max_r']
4025 min_r = self.params['min_r']
4026
4027 assert self.n_imgs >= 3, 'polar grid sample at least 3 points'
4028
4029 num_phi = int(np.ceil((np.sqrt(2 * self.n_imgs - 3) + 3.) / 2.))
4030 num_theta = 2 * (num_phi - 1)
4031 total_imgs = num_theta * (num_phi - 2) + 2
4032
4033 self.cam_poses = []
4034 # cam_poses_neighbors: used in inverse rendering
4035 # neighbor camera positions to be updated
4036 # note that self.cam_poses_neighbors is different from self.target_cam_poses_neighbors
4037 # the former are used in inverse rendering, the later are used in multivew geometry
4038 # but their concept are the same
4039 self.cam_poses_neighbors = []
4040
4041 for i in range(self.total):
4042 poses = []
4043
4044 Hs_c2w, neighbor_ids = utils.generate_camera_polar_grids(
4045 num_phi=num_phi,
4046 num_theta=num_theta,
4047 r=max_r
4048 ) # (n, 4, 4)
4049
4050 for j in range(self.n_imgs):
4051 poses.append(Hs_c2w[j])
4052
4053 self.cam_poses.append(poses)
4054
4055 def _set_manual(self):
4056 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected