flow_homography.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:mrflow 作者: jswulff 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号