flow_io.py 文件源码

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

项目:mrflow 作者: jswulff 项目源码 文件源码
def flow_write_png(u,v,fpath,valid=None):
    """
    Write KITTI optical flow.

    """
    if not has_png:
        print('Error. Please install the PyPNG library')
        return


    if valid==None:
        valid_ = np.ones(u.shape,dtype='uint16')
    else:
        valid_ = valid.astype('uint16')



    u_ = ((u*64.0)+2**15).astype('uint16')
    v_ = ((v*64.0)+2**15).astype('uint16')

    I = np.dstack((u_,v_,valid_))

    W = png.Writer(width=u.shape[1],
                   height=u.shape[0],
                   bitdepth=16,
                   planes=3)

    with open(fpath,'wb') as fil:
        W.write(fil,I.reshape((-1,3*u.shape[1])))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号