def flow2parallax(u,v,q):
"""
Given the flow fields (after correction!) and the epipole,
return:
- The normalized parallax (HxW array)
- The vectors pointing to the epipoles (HxWx2 array)
- The distances of all points to the epipole (HxW array)
"""
h,w = u.shape
y,x = np.mgrid[:h,:w]
u_f = q[0] - x
v_f = q[1] - y
dists = np.sqrt(u_f**2 + v_f**2)
u_f_n = u_f / np.maximum(dists,1e-3)
v_f_n = v_f / np.maximum(dists,1e-3)
parallax = u * u_f_n + v * v_f_n
return parallax, np.dstack((u_f_n, v_f_n)), dists
评论列表
文章目录