iris.nodes.matcher package¶
Submodules¶
iris.nodes.matcher.hamming_distance_matcher module¶
- class iris.nodes.matcher.hamming_distance_matcher.HammingDistanceMatcher(rotation_shift: ConstrainedIntValue = 15, normalise: bool = True, norm_mean: ConstrainedFloatValue = 0.45, norm_gradient: float = 5e-05, separate_half_matching: bool = True, weights_path: str | None = None, weights: List[ndarray] | None = None)[source]¶
Bases:
Matcher
Hamming distance Matcher with additional optional features.
- Algorithm steps:
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.
If parameter norm_mean is defined, calculate normalized Hamming distance (NHD) based on IB_Counts, MB_Counts and norm_mean.
If parameter weights is defined, calculate weighted Hamming distance (WHD) based on IB_Counts, MB_Counts and weights.
If parameters norm_mean and weights are both defined, calculate weighted normalized Hamming distance (WNHD) based on IB_Counts, MB_Counts, norm_mean and weights.
Otherwise, calculate Hamming distance (HD) based on IB_Counts and MB_Counts.
If parameter rotation_shift is > 0, repeat the above steps for additional rotations of the iriscode.
Return the minimum distance from above calculations.
- class Parameters(*, rotation_shift: ConstrainedIntValue, normalise: bool, norm_mean: ConstrainedFloatValue, norm_gradient: float, separate_half_matching: bool, weights_path: str | None = None, weights: List[ndarray] | None = None)[source]¶
Bases:
Parameters
HammingDistanceMatcher parameters.
- norm_gradient: float¶
- norm_mean: ConstrainedFloatValue¶
- normalise: bool¶
- rotation_shift: ConstrainedIntValue¶
- separate_half_matching: bool¶
- weights: List[ndarray] | None¶
- weights_path: str | 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¶
- abstract gallery_to_gallery(template_gallery_1: List[IrisTemplate], template_gallery_2: List[IrisTemplate]) List[List[float]] [source]¶
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]]
- abstract intra_gallery(template_gallery: List[IrisTemplate]) List[List[float]] [source]¶
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¶
- load_weights(weights_path: str) List[array] [source]¶
Load weights from a file.
- Parameters:
weights_path (str) – Path to the weights file.
- Returns:
Loaded weights.
- Return type:
List[Any]
- 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: ConstrainedIntValue = 15, normalise: bool = False, norm_mean: ConstrainedFloatValue = 0.45, norm_gradient: float = 5e-05)[source]¶
Bases:
Matcher
Simple Hamming distance Matcher without the bells and whistles.
- Algorithm steps:
Calculate counts of nonmatch irisbits (IB_Counts) in common unmasked region and the counts of common maskbits (MB_Counts) in common unmasked region.
Calculate Hamming distance (HD) based on IB_Counts and MB_Counts.
If parameter normalise is True, normalize Hamming distance based on parameter norm_mean.
If parameter rotation_shift is > 0, repeat the above steps for additional rotations of the iriscode.
Return the minimium distance from above calculations.
- class Parameters(*, rotation_shift: ConstrainedIntValue, normalise: bool, norm_mean: ConstrainedFloatValue, norm_gradient: float)[source]¶
Bases:
Parameters
SimpleHammingDistanceMatcher parameters.
- norm_gradient: float¶
- norm_mean: ConstrainedFloatValue¶
- normalise: bool¶
- rotation_shift: ConstrainedIntValue¶
- 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] | None = None, weights: List[ndarray] | None = None) Tuple[int, int] | Tuple[List[int], List[int]] [source]¶
Count nonmatch bits for Hamming distance.
- Parameters:
irisbits (np.ndarray) – Nonmatch irisbits.
maskbits (np.ndarray) – Common maskbits.
half_width (Optional[np.ndarray] = None) – List of half of code width. Optional parameter for scoring the upper and lower halves separately. Defaults to None.
weights (Optional[np.ndarray] = None) – List of weights table. Optional parameter for weighted HD. Defaults to None.
- Returns:
Total nonmatch iriscode bit count and common maskcode bit count, could be a list for top and bottom iris separately.
- Return type:
Tuple[int, int]
- iris.nodes.matcher.utils.get_bitcounts(template_probe: IrisTemplate, template_gallery: IrisTemplate, shift: int) ndarray [source]¶
Get bit counts in iris and mask codes.
- Parameters:
template_probe (IrisTemplate) – Iris template from probe.
template_gallery (IrisTemplate) – Iris template from gallery.
shift (int) – Rotation shift (in columns)
- Returns:
Bit counts in iris and mask codes.
- Return type:
np.ndarray
- iris.nodes.matcher.utils.hamming_distance(template_probe: IrisTemplate, template_gallery: IrisTemplate, rotation_shift: int = 15, normalise: bool = False, norm_mean: float = 0.45, norm_gradient: float = 5e-05, separate_half_matching: bool = False, 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. Defaults to 15.
normalise (bool, optional) – Flag to normalize HD. Defaults to False.
norm_mean (float, optional) – Nonmatch mean distance for normalized HD. Defaults to 0.45.
norm_gradient (float) – Gradient for linear approximation of normalization term. Defaults to 0.00005.
separate_half_matching (bool, optional) – Separate the upper and lower halves for matching. Defaults to False.
weights (Optional[List[np.ndarray]], optional) – List of weights table. Optional parameter for weighted HD. Defaults to None.
- Raises:
MatcherError – If probe and gallery iris codes are of different sizes or number of columns of iris codes is not even or If weights (when defined) and iris codes are of different sizes.
- Returns:
Minimum Hamming distance and corresponding rotation shift.
- Return type:
Tuple[float, int]
- iris.nodes.matcher.utils.normalized_HD(irisbitcount: int, maskbitcount: int, norm_mean: float, norm_gradient: float) float [source]¶
Perform normalized HD calculation.
- Parameters:
irisbitcount (int) – Nonmatched iriscode bit count.
maskbitcount (int) – Common maskcode bit count.
norm_mean (float) – Nonmatch distance used for normalized HD.
norm_gradient (float) – Gradient for linear approximation of normalization term.
- 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_gradient: float = 5e-05) Tuple[float, int] [source]¶
Compute Hamming distance, without bells and whistles.
- Parameters:
template_probe (IrisTemplate) – Iris template from probe.
template_gallery (IrisTemplate) – Iris template from gallery.
rotation_shift (int) – Rotations allowed in matching, in columns. Defaults to 15.
normalise (bool) – Flag to normalize HD. Defaults to False.
norm_mean (float) – Peak of the non-match distribution. Defaults to 0.45.
norm_gradient (float) – Gradient for linear approximation of normalization term. Defaults to 0.00005.
- Returns:
Minimum Hamming distance and corresponding rotation shift.
- Return type:
Tuple[float, int]