iris.nodes.geometry_estimation package

Submodules

iris.nodes.geometry_estimation.fusion_extrapolation module

class iris.nodes.geometry_estimation.fusion_extrapolation.FusionExtrapolation(circle_extrapolation: ~iris.io.class_configs.Algorithm = <iris.nodes.geometry_estimation.linear_extrapolation.LinearExtrapolation object>, ellipse_fit: ~iris.io.class_configs.Algorithm = <iris.nodes.geometry_estimation.lsq_ellipse_fit_with_refinement.LSQEllipseFitWithRefinement object>, algorithm_switch_std_threshold: float = 0.014, algorithm_switch_std_conditioned_multiplier: float = 2.0, callbacks: ~typing.List[~iris.callbacks.callback_interface.Callback] = [])[source]

Bases: Algorithm

Fuse two extrapolation strategies and pick the result based on shape statistics.

  1. Circle-like extrapolation: LinearExtrapolation (linear extrapolation algorithm)

  2. Ellipse-like extrapolation: LSQEllipseFitWithRefinement (least square ellipse fit with iris polygon refinement)

By default, the linear extrapolation is used. If the (relative) spread of radii exceeds a threshold and the ellipse-based result looks sufficiently “regular” (based on squared radii ratios), we prefer the ellipse fit.

Notes: - “Relative std” means std/mean with an epsilon guard. - We compare regularity via the relative std of iris/pupil squared-radius ratios under three centering choices (circle/circle, ellipse/ellipse, ellipse/circle).

class Parameters(*, circle_extrapolation: Algorithm, ellipse_fit: Algorithm, algorithm_switch_std_threshold: float, algorithm_switch_std_conditioned_multiplier: float)[source]

Bases: Parameters

Parameters of fusion extrapolation algorithm.

algorithm_switch_std_conditioned_multiplier: float
algorithm_switch_std_threshold: float
circle_extrapolation: Algorithm
ellipse_fit: Algorithm
run(input_polygons: GeometryPolygons, eye_center: EyeCenters) GeometryPolygons[source]

Perform extrapolation algorithm and select the most plausible result.

Parameters:
Returns:

Extrapolated polygons

Return type:

GeometryPolygons

iris.nodes.geometry_estimation.linear_extrapolation module

class iris.nodes.geometry_estimation.linear_extrapolation.LinearExtrapolation(dphi: float = 0.9, callbacks: List[Callback] = [])[source]

Bases: Algorithm

Implementation of geometry estimation algorithm through linear extrapolation in polar space.

Algorithm depends on np.interp therefore it’s better to perform smoothing beforehand.

Algorith steps:
  1. Map iris/pupil polygon vertices to polar space based on estimated iris/pupil centers.

  2. For iris/pupil, perform function interpolation in polar space to estimate missing circle points.

    Note: interpolation in polar space is extrapolation in cartesian space.

  3. Take 2 * np.pi / dphi points from function in polar space.

  4. Map iris/pupil points from polar space back to cartesian space.

class Parameters(*, dphi: ConstrainedFloatValue)[source]

Bases: Parameters

Parameters of linear extrapolation algorithm.

dphi: float
run(input_polygons: GeometryPolygons, eye_center: EyeCenters) GeometryPolygons[source]

Estimate contours.

Parameters:
Returns:

Extrapolated contours.

Return type:

GeometryPolygons

iris.nodes.geometry_estimation.lsq_ellipse_fit_with_refinement module

class iris.nodes.geometry_estimation.lsq_ellipse_fit_with_refinement.LSQEllipseFitWithRefinement(dphi: float = 1.0, callbacks: List[Callback] = [])[source]

Bases: Algorithm

Algorithm that implements least square ellipse fit with iris polygon refinement by finding points to refine by computing euclidean distance.

Algorithm steps:
  1. Use OpenCV’s fitEllipse method to fit an ellipse to predicted iris and pupil polygons.

  2. Refine predicted pupil polygons points to their original location to prevent location precision loss for those points which were predicted by semseg algorithm.

class Parameters(*, dphi: ConstrainedFloatValue)[source]

Bases: Parameters

Parameters of least square ellipse fit extrapolation algorithm.

dphi: float
static parametric_ellipsis(a: float, b: float, x0: float, y0: float, theta: float, nb_step: int = 100) ndarray[source]

Given the parameters of a general ellipsis, returns an array of points in this ellipsis.

Parameters:
  • a (float) – Major axis length.

  • b (float) – Minor axis length.

  • x0 (float) – x offset.

  • y0 (float) – y offset.

  • theta (float) – rotation of the ellipsis.

  • nb_step (int) – number of points in the ellipsis.

Returns:

points within the ellipsis.

Return type:

np.ndarray

run(input_polygons: GeometryPolygons) GeometryPolygons[source]

Estimate extrapolated polygons with OpenCV’s method fitEllipse.

Parameters:

input_polygons (GeometryPolygons) – Smoothed polygons.

Returns:

Extrapolated polygons.

Return type:

GeometryPolygons

Module contents