|
| 1 | +import math |
| 2 | + |
| 3 | +import numpy as np |
| 4 | +import pytest |
| 5 | + |
| 6 | +from iris.io.dataclasses import GeometryPolygons |
| 7 | +from iris.nodes.eye_properties_estimation.circle_fit_for_eye_center_method import CircleFitEyeCenterMethod |
| 8 | +from tests.unit_tests.utils import generate_arc |
| 9 | + |
| 10 | + |
| 11 | +@pytest.fixture |
| 12 | +def algorithm() -> CircleFitEyeCenterMethod: |
| 13 | + return CircleFitEyeCenterMethod(mad_scale=3.0) |
| 14 | + |
| 15 | + |
| 16 | +def test_estimation_on_mock_example(algorithm: CircleFitEyeCenterMethod) -> None: |
| 17 | + pupil_radius = 25.0 |
| 18 | + iris_radius = 100.0 |
| 19 | + eyeball_radius = 400.0 |
| 20 | + pupil_center_x, pupil_center_y = 95.0, 145.0 |
| 21 | + iris_center_x, iris_center_y = 100.0, 155.0 |
| 22 | + |
| 23 | + mock_polygons = GeometryPolygons( |
| 24 | + pupil_array=generate_arc(pupil_radius, pupil_center_x, pupil_center_y, 0.0, 2 * np.pi), |
| 25 | + iris_array=generate_arc(iris_radius, iris_center_x, iris_center_y, 0.0, 2 * np.pi), |
| 26 | + eyeball_array=generate_arc(eyeball_radius, iris_center_x, iris_center_y, 0.0, 2 * np.pi), |
| 27 | + ) |
| 28 | + |
| 29 | + result = algorithm(mock_polygons) |
| 30 | + |
| 31 | + assert math.isclose(result.pupil_x, pupil_center_x, rel_tol=0.1) |
| 32 | + assert math.isclose(result.pupil_y, pupil_center_y, rel_tol=0.1) |
| 33 | + assert math.isclose(result.iris_x, iris_center_x, rel_tol=0.1) |
| 34 | + assert math.isclose(result.iris_y, iris_center_y, rel_tol=0.1) |
0 commit comments