Exemple #1
0
def test_undistort_static_radtan():
    image = imread(DATA_DIR / "static-cam0-98.png")
    expected = imread(DATA_DIR / "static-cam0-98-undistorted-radtan.png")
    intrinsics_file = DATA_DIR / "camchain-static-radtan.yaml"
    cam = CameraIntrinsics.from_kalibr_yaml(intrinsics_file, "cam0")
    actual = cam.get_undistorter(extent=ImageExtent.OnlyValid).undistort_image(image)
    assert np.allclose(actual, expected)
Exemple #2
0
def load_chess1():
    """Load OpenCV test data."""
    data_dir = Path(__file__).parent / "data"
    image = imread(data_dir / "chess1.png")
    corners = yaml.load(open(data_dir / "chess_corners1.dat"),
                        Loader=yaml.SafeLoader)["corners"]
    shape = (corners["cols"], corners["rows"])
    expected = np.array(corners["data"]).reshape((-1, 2))
    return image, shape, expected
Exemple #3
0
def test_imread_invalid(tmp_path):
    file = tmp_path.joinpath("temp.png")
    file.touch()
    with pytest.raises(IOError):
        imread(file)
Exemple #4
0
def test_imread():
    image = imread(Path(__file__).parent / "data/chess1.png")
    assert image.shape == (240, 320)
Exemple #5
0
def test_imread_missing():
    with pytest.raises(FileNotFoundError):
        imread("missing_file.png")