【发布时间】:2020-04-11 17:05:39
【问题描述】:
我有一个问题,我有一组图像并且必须根据第一张图像的帧计算相机轨迹。
在 OpenCV 中,有很多方法可以首先在图像中找到特征,然后在图像之间进行匹配,然后再应用视觉里程计。
"""
Estimate complete camera trajectory from subsequent image pairs
Arguments:
estimate_motion -- a function which estimates camera motion from a pair of subsequent image frames
matches -- list of matches for each subsequent image pair in the dataset.
Each matches[i] is a list of matched features from images i and i + 1
kp_list -- a list of keypoints for each image in the dataset
k -- camera calibration matrix
"""
for i in range(len(matches)):
match = matches[i]
kp1 = kp_list[i]
kp2 = kp_list[i+1]
depth = depth_maps[i]
rmat, tvec, image1_points, image2_points = estimate_motion(match, kp1, kp2, k, depth)
R = rmat
t = np.array([tvec[0,0],tvec[1,0],tvec[2,0]])
P_new = np.eye(4)
P_new[0:3,0:3] = R.T
P_new[0:3,3] = (-R.T).dot(t)
P = P.dot(P_new)
trajectory.append(P[:3,3])
trajectory = np.array(trajectory).T
trajectory[2,:] = -1*trajectory[2,:]
在estimate_motion 中,旋转矩阵和平移向量被返回,但此时相对于 image1。由于我想获得第一张图像的帧中的轨迹,因此我必须将其转换为该帧,但我不明白:
- 为什么
P_new[0:3,0:3] = R.T会被转置 - 为什么
P_new[0:3,3] = (-R.T).dot(t)是负号
【问题讨论】:
-
为什么不使用光流来计算鼠标控制器的运动?
-
@lamourettejean-baptiste 光流可用于 VO,但这不是 OP 问题。这里有一些Visual Odometry 主题的参考资料。