Ejemplo n.º 1
0
    def test_flow_with_arrows(self):
        flow = flowpy.flow_read("static/kitti_occ_000010_10.png")

        fig, ax = plt.subplots()
        ax.imshow(flowpy.flow_to_rgb(flow))
        flowpy.attach_arrows(ax, flow, xy_steps=(20, 20), scale=1)

        plt.show()
Ejemplo n.º 2
0
    def test_flow_arrows_and_coord(self):
        flow = flowpy.flow_read("static/Dimetrodon.flo")

        fig, ax = plt.subplots()
        ax.imshow(flowpy.flow_to_rgb(flow))
        flowpy.attach_arrows(ax, flow)
        flowpy.attach_coord(ax, flow)

        plt.show()
Ejemplo n.º 3
0
    def test_forward_warp_rgb(self):
        flow = flowpy.flow_read("static/kitti_occ_000010_10.png")
        first_image = np.asarray(Image.open("static/kitti_000010_10.png"))
        second_image = np.asarray(Image.open("static/kitti_000010_11.png"))

        flow[np.isnan(flow)] = 0
        warped_second_image = flowpy.forward_warp(first_image, flow, k=1)

        fig, (ax_1, ax_2, ax_3) = plt.subplots(3, 1)
        ax_1.imshow(first_image)
        ax_2.imshow(flowpy.flow_to_rgb(flow))
        ax_3.imshow(warped_second_image)

        plt.show()
Ejemplo n.º 4
0
    def test_flow_arrows_coord_and_calibration_pattern(self):
        flow = flowpy.flow_read("static/Dimetrodon.flo")
        height, width, _ = flow.shape
        image_ratio = height / width

        max_radius = flowpy.get_flow_max_radius(flow)

        fig, (ax_1, ax_2) = plt.subplots(
            1, 2, gridspec_kw={"width_ratios": [1, image_ratio]})

        ax_1.imshow(flowpy.flow_to_rgb(flow))
        flowpy.attach_arrows(ax_1, flow)
        flowpy.attach_coord(ax_1, flow)

        flowpy.attach_calibration_pattern(ax_2, flow_max_radius=max_radius)

        plt.show()
Ejemplo n.º 5
0
    t3 = args.img_list[0].split('_')
    t0 = t3[2].split('.')
    t = args.img_list[1].split('_')
    t1 = t[2].split('.')

    ts = TestHelper(cfg)

    imgs = [imageio.imread(img).astype(np.float32) for img in args.img_list]
    h, w = imgs[0].shape[:2]

    flow_12 = ts.run(imgs)['flows_fw'][0]

    flow_12 = resize_flow(flow_12, (h, w))
    np_flow_12 = flow_12[0].detach().cpu().numpy().transpose([1, 2, 0])

    vis_flow = flowpy.flow_to_rgb(np_flow_12)

    cv2.imwrite(t0[0] + " " + t1[0] + ".png", vis_flow)

    #=flow_warp(im2, flow12, pad='border', mode='bilinear'):
    first_image = np.asarray(Image.open(args.img_list[0]))
    cv2.imwrite(t0[0] + ".png", first_image)
    second_image = np.asarray(Image.open(args.img_list[1]))

    np_flow_12[np.isnan(np_flow_12)] = 0
    warped_first_image = flowpy.backward_warp(second_image, np_flow_12)

    cv2.imwrite("warped_oc" + t1[0] + ".png", warped_first_image)

    def PSNR(original, compressed):
        mse = np.mean((original - compressed)**2)
Ejemplo n.º 6
0
 def test_flow_to_rgb(self):
     flow = flowpy.flow_read("static/Dimetrodon.flo")
     plt.imshow(flowpy.flow_to_rgb(flow))
     plt.show()
Ejemplo n.º 7
0
"""

# Examples a simple RGB plot
"""
This is the simplest example of how to use flowpy, it:
Reads a file using flowpy.flow_read.
Transforms the flow as an rgb image with flowpy.flow_to_rgb and shows it with matplotlib
"""

import flowpy
import matplotlib.pyplot as plt

flow = flowpy.flow_read("tests/data/kitti_occ_000010_10.flo")

fig, ax = plt.subplots()
ax.imshow(flowpy.flow_to_rgb(flow))
plt.show()

# Plotting arrows, showing flow values and a calibration pattern

# Flowpy comes with more than just RGB plots, the main features here are: - Arrows to quickly visualize the flow -
# The flow values below cursor showing in the tooltips - A calibration pattern side by side as a legend for your graph

flow = flowpy.flow_read("tests/data/Dimetrodon.flo")
height, width, _ = flow.shape

image_ratio = height / width
max_radius = flowpy.get_flow_max_radius(flow)

fig, (ax_1,
      ax_2) = plt.subplots(1,