def get_residual_flow(x,y,u,v,H):
""" Removes homography from flow
Parameters: x,y,u,v,H.
"""
x2 = x + u
y2 = y + v
pt2_ = np.c_[x2.ravel(),y2.ravel()].astype('float32')
pt1_ = np.c_[x.ravel(),y.ravel()].astype('float32')
Hinv = np.linalg.inv(H)
uv_ = cv2.perspectiveTransform(pt2_[:,np.newaxis,:],Hinv).squeeze() - pt1_
return uv_[:,0].reshape(x.shape), uv_[:,1].reshape(x.shape)
评论列表
文章目录