Ejemplo n.º 1
0
def flow2rgb(flow, image_dimension):
    # convert flow field to an rgb image
    flow_image = cvb.flow2rgb(flow)
    flow_image *= 255
    flow_image = resize(flow_image, image_dimension)
    flow_image = np.array(flow_image,dtype = np.uint8)
    return flow_image
Ejemplo n.º 2
0
def write_flows(flow_lists, index, debug_out_dir):
    if not os.path.exists(debug_out_dir):
        os.makedirs(debug_out_dir)
    for key, flow in flow_lists.items():
        flow_img = cvb.flow2rgb(flow)
        # import pdb; pdb.set_trace();
        fn = os.path.join(debug_out_dir, '{}_{}.png'.format(index, key))
        cv2.imwrite(fn, np.array(flow_img * 255.0).astype(np.uint8))
Ejemplo n.º 3
0
def test_flow2rgb():
    flow = np.array(
        [[[0, 0], [0.5, 0.5], [1, 1], [2, 1], [3, np.inf]]], dtype=np.float32)
    flow_img = cvb.flow2rgb(flow)
    # yapf: disable
    assert_array_almost_equal(
        flow_img,
        np.array([[[1., 1., 1.],
                   [1., 0.826074731, 0.683772236],
                   [1., 0.652149462, 0.367544472],
                   [1., 0.265650552, 5.96046448e-08],
                   [0., 0., 0.]]],
                 dtype=np.float32))
Ejemplo n.º 4
0
#!/usr/bin/env python

import cvbase as cvb
import glob
import argparse
import os
import matplotlib.pyplot as plt

parser = argparse.ArgumentParser()
parser.add_argument('arg1', type=str, help='Input dir')
args = parser.parse_args()

path = args.arg1
outdir = os.path.split(path)
print(outdir)
outdir = os.path.join(outdir[0], outdir[1] + '_vis')
if not os.path.exists(outdir):
    os.mkdir(outdir)

flos = glob.glob(os.path.join(path, '*flo'))
print(len(flos), 'flo files found.')
for flo in flos:
    flow = cvb.read_flow(flo)
    img = cvb.flow2rgb(flow)
    plt.imsave(os.path.join(outdir, os.path.basename(flo) + '.png'), img)
Ejemplo n.º 5
0
def flow2rgbimg(real_flow):
    flow_img = cvb.flow2rgb(real_flow)
    bgr_img = cvb.rgb2bgr(flow_img)
    return bgr_img
Ejemplo n.º 6
0
# convert .flo to rgb and visualize
import numpy as np
import cvbase as cvb
from skimage.io import imsave

flow_name = 'out.flo'
flow = cvb.read_flow(flow_name)
a = cvb.flow2rgb(flow)
imsave('a.png', a)