如何使用KITTI里程计数据集评估单目视觉里程计结果

2024-09-29 19:22:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用KITTI开放数据集进行单目视觉里程测量 我试着用这个repo

它使用此代码将姿势转换为6自由度

def get6DoFPose(self, p):
    pos = np.array([p[3], p[7], p[11]])
    R = np.array([[p[0], p[1], p[2]], [p[4], p[5], p[6]], [p[8], p[9], p[10]]])
    angles = self.rotationMatrixToEulerAngles(R)
    return np.concatenate((pos, angles))

def isRotationMatrix(self, R):
    Rt = np.transpose(R)
    shouldBeIdentity = np.dot(Rt, R)
    I = np.identity(3, dtype=R.dtype)
    n = np.linalg.norm(I - shouldBeIdentity)
    return n < 1e-6

def rotationMatrixToEulerAngles(self, R):
    assert (self.isRotationMatrix(R))
    sy = math.sqrt(R[0, 0] * R[0, 0] + R[1, 0] * R[1, 0])
    singular = sy < 1e-6

    if not singular:
        x = math.atan2(R[2, 1], R[2, 2])
        y = math.atan2(-R[2, 0], sy)
        z = math.atan2(R[1, 0], R[0, 0])
    else:
        x = math.atan2(-R[1, 2], R[1, 1])
        y = math.atan2(-R[2, 0], sy)
        z = 0
    return np.array([x, y, z], dtype=np.float32)

此外,模型输出的格式相同(6自由度)

问题是如何评估6DoF结果,因为此评估工具(kitti-odom-eval)仅支持以下两种格式

# First format: skipping frames are allowed
99 T00 T01 T02 T03 T10 T11 T12 T13 T20 T21 T22 T23 

# Second format: all poses should be included in the file
T00 T01 T02 T03 T10 T11 T12 T13 T20 T21 T22 T23 

Tags: posselfreturndefnpmatharrayangles

热门问题