iris.nodes.matcher package

Submodules

iris.nodes.matcher.hamming_distance_matcher module

class iris.nodes.matcher.hamming_distance_matcher.HammingDistanceMatcher(rotation_shift: int = 15, normalise: bool = False, nm_dist: ConstrainedFloatValue = 0.45, nm_type: Literal['linear', 'sqrt'] = 'sqrt', weights: List[ndarray] | None = None)[source]

Bases: Matcher

Hamming distance Matcher.

Algorithm steps:
  1. Calculate counts of nonmatch irisbits (IB_Counts) in common unmasked region and the counts of common maskbits (MB_Counts) in common unmasked region for both upper and lower half of iris, respectively.

  2. If parameter nm_dist is defined, calculate normalized Hamming distance (NHD) based on IB_Counts, MB_Counts and nm_dist.

  3. If parameter weights is defined, calculate weighted Hamming distance (WHD) based on IB_Counts, MB_Counts and weights.

  4. If parameters nm_dist and weights are both defined, calculate weighted normalized Hamming distance (WNHD) based on IB_Counts, MB_Counts, nm_dist and weights.

  5. Otherwise, calculate Hamming distance (HD) based on IB_Counts and MB_Counts.

  6. If parameter rotation_shift is > 0, repeat the above steps for additional rotations of the iriscode.

  7. Return the minimium distance from above calculations.

class Parameters(*, rotation_shift: ConstrainedIntValue, normalise: bool, nm_dist: ConstrainedFloatValue, nm_type: Literal['linear', 'sqrt'], weights: List[ndarray] | None = None)[source]

Bases: Parameters

IrisMatcherParameters parameters.

nm_dist: ConstrainedFloatValue
nm_type: Literal['linear', 'sqrt']
normalise: bool
weights: List[ndarray] | None
run(template_probe: IrisTemplate, template_gallery: IrisTemplate) float[source]

Match iris templates using Hamming distance.

Parameters:
  • template_probe (IrisTemplate) – Iris template from probe.

  • template_gallery (IrisTemplate) – Iris template from gallery.

Returns:

matching distance.

Return type:

float

iris.nodes.matcher.hamming_distance_matcher_interface module

class iris.nodes.matcher.hamming_distance_matcher_interface.BatchMatcher(**kwargs: Any)[source]

Bases: ABC

Parent Abstract class for 1-to-N matchers.

class Parameters(*, rotation_shift: ConstrainedIntValue)[source]

Bases: ImmutableModel

IrisMatcherParameters parameters.

rotation_shift: ConstrainedIntValue

Match iris templates using Hamming distance.

Parameters:
  • template_gallery_1 (List[IrisTemplate]) – Iris template gallery.

  • template_gallery_2 (List[IrisTemplate]) – Iris template gallery.

Returns:

matching distances.

Return type:

List[List[float]]

Match iris templates using Hamming distance.

Parameters:

template_gallery (List[IrisTemplate]) – Iris template gallery.

Returns:

matching distances.

Return type:

List[List[float]]

class iris.nodes.matcher.hamming_distance_matcher_interface.Matcher(**kwargs)[source]

Bases: ABC

Parent Abstract class for 1-to-1 matchers.

class Parameters(*, rotation_shift: ConstrainedIntValue)[source]

Bases: ImmutableModel

IrisMatcherParameters parameters.

rotation_shift: ConstrainedIntValue
abstract run(template_probe: IrisTemplate, template_gallery: IrisTemplate) float[source]

Match iris templates using Hamming distance.

Parameters:
  • template_probe (IrisTemplate) – Iris template from probe.

  • template_gallery (IrisTemplate) – Iris template from gallery.

Returns:

matching distance.

Return type:

float

iris.nodes.matcher.simple_hamming_distance_matcher module

class iris.nodes.matcher.simple_hamming_distance_matcher.SimpleHammingDistanceMatcher(rotation_shift: int = 15, normalise: bool = False, norm_mean: float = 0.45, norm_nb_bits: float = 12288)[source]

Bases: Matcher

Hamming distance Matcher, without the bells and whistles.

Algorithm steps:
  1. Calculate counts of nonmatch irisbits (IB_Counts) in common unmasked region and the counts of common maskbits (MB_Counts) in common unmasked region.

  2. Calculate Hamming distance (HD) based on IB_Counts and MB_Counts.

  3. If parameter normalise is True, normalize Hamming distance based on parameter norm_mean and parameter norm_nb_bits.

  4. If parameter rotation_shift is > 0, repeat the above steps for additional rotations of the iriscode.

  5. Return the minimium distance from above calculations.

class Parameters(*, rotation_shift: ConstrainedIntValue, normalise: bool, norm_mean: ConstrainedFloatValue, norm_nb_bits: ConstrainedIntValue)[source]

Bases: Parameters

IrisMatcherParameters parameters.

norm_mean: ConstrainedFloatValue
norm_nb_bits: ConstrainedIntValue
normalise: bool
run(template_probe: IrisTemplate, template_gallery: IrisTemplate) float[source]

Match iris templates using Hamming distance.

Parameters:
  • template_probe (IrisTemplate) – Iris template from probe.

  • template_gallery (IrisTemplate) – Iris template from gallery.

Returns:

matching distance.

Return type:

float

iris.nodes.matcher.utils module

iris.nodes.matcher.utils.count_nonmatchbits(irisbits: ndarray, maskbits: ndarray, half_width: List[int], weights: List[ndarray] | None = None) Tuple[int, int, int, int][source]

Count nonmatch bits for Hammming distance.

Parameters:
  • irisbits (np.ndarray) – nonmatch irisbits.

  • maskbits (np.ndarray) – common maskbits.

  • half_width (List[int]) – list of half of code width.

  • weights (Optional[np.ndarray] = None) – list of weights table. Optional paremeter for weighted HD. Defaults to None.

Returns:

nonmatch iriscode bit count and common maskcode bit count from top iris and bottom iris.

Return type:

Tuple[int, int, int, int]

iris.nodes.matcher.utils.count_sqrt_totalbits(toal_codesize: int, half_width: List[int], weights: List[ndarray] | None = None) Tuple[float, float, float][source]

Count total amount of sqrt bits.

Parameters:
  • toal_codesizes (int) – total size of iriscodes.

  • half_width (List[int]) – half width of iriscodes.

  • weights (Optional[List[np.ndarray]] = None) – list of weights table. Optional paremeter for weighted HD. Defaults to None.

Returns:

square root of bit counts from whole iris, top iris and bottom iris.

Return type:

Tuple[float, float, float]

iris.nodes.matcher.utils.hamming_distance(template_probe: IrisTemplate, template_gallery: IrisTemplate, rotation_shift: int, normalise: bool = False, nm_dist: float = 0.45, nm_type: Literal['linear', 'sqrt'] = 'sqrt', weights: List[ndarray] | None = None) Tuple[float, int][source]

Compute Hamming distance.

Parameters:
  • template_probe (IrisTemplate) – Iris template from probe.

  • template_gallery (IrisTemplate) – Iris template from gallery.

  • rotation_shift (int) – rotation allowed in matching, converted to columns.

  • normalise (bool) – Flag to normalize HD. Defaults to False.

  • nm_dist (float) – nonmatch mean distance for normalized HD. Defaults to 0.45.

  • nm_type (Literal["linear", "sqrt"]) – type of normalized HD. Defaults to “sqrt”.

  • weights (Optional[List[np.ndarray]]= None) – list of weights table. Optional paremeter for weighted HD. Defaults to None.

Returns:

miminum Hamming distance and corresonding rotation shift.

Return type:

Tuple[float, int]

iris.nodes.matcher.utils.normalized_HD(irisbitcount: int, maskbitcount: int, sqrt_totalbitcount: float, nm_dist: float) float[source]

Perform normalized HD calculation.

Parameters:
  • irisbitcount (int) – nonmatched iriscode bit count.

  • maskbitcount (int) – common maskcode bit count.

  • sqrt_totalbitcount (float) – square root of bit counts.

  • nm_dist (float) – nonmatch distance used for normalized HD.

Returns:

normalized Hamming distance.

Return type:

float

iris.nodes.matcher.utils.simple_hamming_distance(template_probe: IrisTemplate, template_gallery: IrisTemplate, rotation_shift: int = 15, normalise: bool = False, norm_mean: float = 0.45, norm_nb_bits: float = 12288) Tuple[float, int][source]

Compute Hamming distance, without bells and whistles. :param template_probe: Iris template from probe. :type template_probe: IrisTemplate :param template_gallery: Iris template from gallery. :type template_gallery: IrisTemplate :param rotation_shift: Rotations allowed in matching, in columns. Defaults to 15. :type rotation_shift: int :param normalise: Flag to normalize HD. Defaults to False. :type normalise: bool :param norm_mean: Peak of the non-match distribution. Defaults to 0.45. :type norm_mean: float :param norm_nb_bits: Average number of bits visible in 2 randomly sampled iris codes. Defaults to 12288 (3/4 * total_bits_number for the iris code format v0.1). :type norm_nb_bits: float

Returns:

miminum Hamming distance and corresonding rotation shift.

Return type:

Tuple[float, int]

Module contents