MCPcopy Create free account
hub / github.com/SceneFun3D/scenefun3d / TrajStringToMatrix

Method TrajStringToMatrix

utils/data_parser.py:138–172  ·  view source on GitHub ↗

Converts a line from the camera trajectory file into translation and rotation matrices. Args: traj_str (str): A space-delimited string where each line represents a camera pose at a particular timestamp. The line consists of seven columns:

(self, traj_str)

Source from the content-addressed store, hash-verified

136 self.data_root_path = os.path.join(data_root_path)
137
138 def TrajStringToMatrix(self, traj_str):
139 """
140 Converts a line from the camera trajectory file into translation and rotation matrices.
141
142 Args:
143 traj_str (str): A space-delimited string where each line represents a camera pose at a particular timestamp.
144 The line consists of seven columns:
145 - Column 1: timestamp
146 - Columns 2-4: rotation (axis-angle representation in radians)
147 - Columns 5-7: translation (in meters)
148
149 Returns:
150 (tuple): A tuple containing:
151 - ts (str): Timestamp.
152 - Rt (numpy.ndarray): 4x4 transformation matrix representing rotation and translation.
153
154 Raises:
155 AssertionError: If the input string does not have exactly seven columns.
156 """
157 tokens = traj_str.split()
158 assert len(tokens) == 7
159 ts = tokens[0]
160
161 # Rotation in angle axis
162 angle_axis = [float(tokens[1]), float(tokens[2]), float(tokens[3])]
163 r_w_to_p = convert_angle_axis_to_matrix3(np.asarray(angle_axis))
164
165 # Translation
166 t_w_to_p = np.asarray([float(tokens[4]), float(tokens[5]), float(tokens[6])])
167 extrinsics = np.eye(4, 4)
168 extrinsics[:3, :3] = r_w_to_p
169 extrinsics[:3, -1] = t_w_to_p
170 Rt = np.linalg.inv(extrinsics)
171
172 return (ts, Rt)
173
174 def get_camera_trajectory(self, visit_id, video_id, pose_source="colmap"):
175 """

Callers 1

get_camera_trajectoryMethod · 0.95

Calls 1

Tested by

no test coverage detected