def get_full_flow(u_res,v_res,H,x=None,y=None,shape=None):
""" Adds homography back into flow
Parameters: x,y,u,v,H
"""
if (shape is None) and (x is None or y is None):
print('Please provide either x/y or the shape.')
if x is None and y is None:
x,y = np.meshgrid(np.arange(shape[1]),np.arange(shape[0]))
x2 = x + u_res
y2 = y + v_res
pt2_ = np.c_[x2.ravel(),y2.ravel()].astype('float32')
pt1_ = np.c_[x.ravel(),y.ravel()].astype('float32')
uv_ = cv2.perspectiveTransform(pt2_[:,np.newaxis,:],H).squeeze() - pt1_
return uv_[:,0].reshape(x.shape), uv_[:,1].reshape(x.shape)
评论列表
文章目录