def homography2flow(x,y,H):
""" Convert homography to flow field
"""
pt1_ = np.c_[x.ravel(),y.ravel()].astype('float32')
uv = cv2.perspectiveTransform(pt1_[:,np.newaxis,:],H).squeeze() - pt1_
return uv[:,0].reshape(x.shape), uv[:,1].reshape(x.shape)
评论列表
文章目录