MCPcopy Create free account
hub / github.com/ActiveVisionLab/DFNet / normalize_recenter_pose

Function normalize_recenter_pose

dataset_loaders/cambridge_scenes.py:78–104  ·  view source on GitHub ↗

normalize xyz into [-1, 1], and recenter pose

(poses, sc, hwf)

Source from the content-addressed store, hash-verified

76 return m
77
78def normalize_recenter_pose(poses, sc, hwf):
79 ''' normalize xyz into [-1, 1], and recenter pose '''
80 target_pose = poses.reshape(poses.shape[0],3,4)
81 target_pose[:,:3,3] = target_pose[:,:3,3] * sc
82
83
84 x_norm = target_pose[:,0,3]
85 y_norm = target_pose[:,1,3]
86 z_norm = target_pose[:,2,3]
87
88 tpose_ = target_pose+0
89
90 # find the center of pose
91 center = np.array([x_norm.mean(), y_norm.mean(), z_norm.mean()])
92 bottom = np.reshape([0,0,0,1.], [1,4])
93
94 # pose avg
95 vec2 = normalize(tpose_[:, :3, 2].sum(0))
96 up = tpose_[:, :3, 1].sum(0)
97 hwf=np.array(hwf).transpose()
98 c2w = np.concatenate([viewmatrix(vec2, up, center), hwf], 1)
99 c2w = np.concatenate([c2w[:3,:4], bottom], -2)
100
101 bottom = np.tile(np.reshape(bottom, [1,1,4]), [tpose_.shape[0],1,1])
102 poses = np.concatenate([tpose_[:,:3,:4], bottom], -2)
103 poses = np.linalg.inv(c2w) @ poses
104 return poses[:,:3,:].reshape(poses.shape[0],12)
105
106def downscale_pose(poses, sc):
107 ''' downscale translation pose to [-1:1] only '''

Callers

nothing calls this directly

Calls 2

normalizeFunction · 0.70
viewmatrixFunction · 0.70

Tested by

no test coverage detected