コード例 #1
0
    def test_unproject_random(self):
        """Test the unproject function using random 2d points."""
        point_2d = np.random.uniform(size=(100, 2))
        depth = np.random.uniform(size=(100, 1))

        pred = orthographic.unproject(point_2d, depth)

        self.assertAllEqual(pred[:, 0:2], point_2d)
        self.assertAllEqual(pred[:, 2], np.squeeze(depth))
コード例 #2
0
    def test_unproject_jacobian_random(self):
        """Test the Jacobian of the unproject function."""
        tensor_size = np.random.randint(3)
        tensor_shape = np.random.randint(1, 10, size=(tensor_size)).tolist()
        point_2d_init = np.random.uniform(size=tensor_shape + [2])
        depth_init = np.random.uniform(size=tensor_shape + [1])
        point_2d = tf.convert_to_tensor(value=point_2d_init)
        depth = tf.convert_to_tensor(value=depth_init)

        y = orthographic.unproject(point_2d, depth)

        self.assert_jacobian_is_correct(point_2d, point_2d_init, y)
        self.assert_jacobian_is_correct(depth, depth_init, y)