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

Function average_poses

dataset_loaders/load_7Scenes.py:138–165  ·  view source on GitHub ↗

Calculate the average pose, which is then used to center all poses using @center_poses. Its computation is as follows: 1. Compute the center: the average of pose centers. 2. Compute the z axis: the normalized average z axis. 3. Compute axis y': the average y axis. 4. Compute

(poses)

Source from the content-addressed store, hash-verified

136 return v / np.linalg.norm(v)
137
138def average_poses(poses):
139 """
140 Calculate the average pose, which is then used to center all poses
141 using @center_poses. Its computation is as follows:
142 1. Compute the center: the average of pose centers.
143 2. Compute the z axis: the normalized average z axis.
144 3. Compute axis y': the average y axis.
145 4. Compute x' = y' cross product z, then normalize it as the x axis.
146 5. Compute the y axis: z cross product x.
147 Note that at step 3, we cannot directly use y' as y axis since it's
148 not necessarily orthogonal to z axis. We need to pass from x to y.
149 Inputs:
150 poses: (N_images, 3, 4)
151 Outputs:
152 pose_avg: (3, 4) the average pose
153 """
154 # 1. Compute the center
155 center = poses[..., 3].mean(0) # (3)
156 # 2. Compute the z axis
157 z = normalize(poses[..., 2].mean(0)) # (3)
158 # 3. Compute axis y' (no need to normalize as it's not the final output)
159 y_ = poses[..., 1].mean(0) # (3)
160 # 4. Compute the x axis
161 x = normalize(np.cross(y_, z)) # (3)
162 # 5. Compute the y axis (as z and x are normalized, y is already of norm 1)
163 y = np.cross(z, x) # (3)
164 pose_avg = np.stack([x, y, z, center], 1) # (3, 4)
165 return pose_avg
166
167def center_poses(poses, pose_avg_from_file=None):
168 """

Callers 1

center_posesFunction · 0.70

Calls 1

normalizeFunction · 0.70

Tested by

no test coverage detected