Evaluation code
ponimatkin opened this issue · 1 comments
ponimatkin commented
Hi, thanks for the great work!
I wanted to ask, could you please show how did you evaluate ID-Pose on the datasets in the paper? More precisely, how did you convert (elevation, azimuth, radius) predictions to rotation matrices?
Thank you!
xt4d commented
Thanks for your interest!
We evaluate the rotation matrix as follows:
- Add the prediction of the relative pose (elevation, azimuth, radius) with the anchor view pose.
- Convert the spherical pose to cartesian (x, y, z), which is the camera "eye" position.
- Obtain the camera2world matrix with "lookAt"=(0, 0, 0) and "up"=(0, 0, 1)
- Obtain the rotation matrix from the world2camera matrix.
- Compute the angular error with the ground truth rotation.
Here are the functions used in our evaluations:
def spherical_to_cartesian(sph):
theta, azimuth, radius = sph
return np.array([
radius * np.sin(theta) * np.cos(azimuth),
radius * np.sin(theta) * np.sin(azimuth),
radius * np.cos(theta),
])
def elu_to_c2w(eye, lookat, up):
if isinstance(eye, list):
eye = np.array(eye)
if isinstance(lookat, list):
lookat = np.array(lookat)
if isinstance(up, list):
up = np.array(up)
l = eye - lookat
l = l / np.linalg.norm(l)
s = np.cross(l, up)
s = s / np.linalg.norm(s)
uu = np.cross(s, l)
rot = np.eye(3)
rot[0, :] = -s
rot[1, :] = uu
rot[2, :] = l
c2w = np.eye(4)
c2w[:3, :3] = rot.T
c2w[:3, 3] = eye
return c2w
def compute_angular_error(rotation1, rotation2):
R_rel = rotation1.T @ rotation2
tr = (np.trace(R_rel) - 1) / 2
theta = np.arccos(tr.clip(-1, 1))
return theta * 180 / np.pi