Exemplo n.º 1
0
 def test_of(self):
     img0 = cv2.imread(path_dir_data + 'sintel1.png')[:, :, ::-1]
     img1 = cv2.imread(path_dir_data + 'sintel2.png')[:, :, ::-1]
     u, v = fastdeepflow.calc_flow(img0, img1)
     u1, v1 = fastdeepflow.read_flow(path_dir_data + 'sintel_cmd.flo')
     self.assertTrue(numpy.allclose(u, u1, atol=1e-8))
     self.assertTrue(numpy.allclose(v, v1, atol=1e-8))
Exemplo n.º 2
0
    def test_wrap_grayscale(self):
        img0 = cv2.imread(path_dir_data + 'sintel1.png')[:, :, ::-1]
        img1 = cv2.imread(path_dir_data + 'sintel2.png')[:, :, ::-1]
        u, v = fastdeepflow.read_flow(path_dir_data + 'sintel_cmd.flo')
        img1warped = fastdeepflow.warp_image(img1, u, v)

        z = [fastdeepflow.warp_image(img1[:, :, k], u, v) for k in range(3)]
        zz = numpy.dstack(z, )

        self.assertTrue(numpy.allclose(img1warped, zz, atol=1e-8))
Exemplo n.º 3
0
    def prepare(self, dir_name, path_flow_reference):

        img0 = imread(
            os.path.join(path_dir_data, 'artificial/%s/img0.png' % dir_name))
        img1 = imread(
            os.path.join(path_dir_data, 'artificial/%s/img1.png' % dir_name))

        flow_reference = fastdeepflow.read_flow(
            os.path.join(path_dir_data,
                         ('artificial/%s/' + path_flow_reference) % dir_name))

        return img0, img1, flow_reference
Exemplo n.º 4
0
    def test_read_write(self):
        path_tmp_flow = os.path.join(path_dir_data, 'flow_read_write_test.flo')
        if os.path.exists(path_tmp_flow):
            os.remove(path_tmp_flow)
        self.assertFalse(os.path.exists(path_tmp_flow))

        self.assertEqual(self.u.shape, self.v.shape)

        fastdeepflow.write_flow(path_tmp_flow, self.u, self.v)
        self.assertTrue(os.path.exists(path_tmp_flow))
        u_loaded, v_loaded = fastdeepflow.read_flow(path_tmp_flow)
        self.assertTrue(numpy.array_equal(self.u, u_loaded))
        self.assertTrue(numpy.array_equal(self.v, v_loaded))
Exemplo n.º 5
0
    def test_read_write(self):
        with self.assertRaises(Exception):
            fastdeepflow.write_flow('123123/123/123123', self.u, self.v)

        with self.assertRaises(Exception):
            res = fastdeepflow.read_flow('123123/234234')
Exemplo n.º 6
0
 def setUp(self):
     self.u, self.v = fastdeepflow.read_flow(path_dir_data +
                                             'sintel_cmd.flo')
     self.assertTrue(self.u.max() - self.u.min() > 5)