Skip to main content

Crate fprint_pipeline

Crate fprint_pipeline 

Source
Expand description

§fprint-pipeline

The host-image fingerprint pipeline. It joins the three published leaves — fprint_mindtct (minutiae detection), fprint_bozorth3 (minutiae matching) and fprint_core (the domain Print / Template / Minutia) — into the one path a host-image sensor walks: image → minutiae → template → match.

The two kernels are dependency-free and each defines its own Minutia (the xyt triple is an interoperability fact, not a shared type). This crate owns the small conversions between them and the domain model:

Add just this crate: it re-exports fprint_core, fprint_mindtct and fprint_bozorth3, so the domain types and the kernels are reachable without naming them as separate dependencies.

§Image → template → match

use fprint_pipeline::{
    nbis_identify, nbis_match_score, nbis_verify, template_from_images, GrayImage,
};

// A procedural fingerprint-like frame: dark horizontal ridges with a gap cut into every other
// ridge. A gap ends a ridge, and a ridge ending is a minutia (plain stripes would have none).
fn synthetic_frame() -> Vec<u8> {
    let (w, h) = (128usize, 128usize);
    (0..w * h)
        .map(|i| {
            let (x, y) = (i % w, i / w);
            let on_ridge = (y % 8) < 4;
            let gap = (48..80).contains(&x) && (y / 8) % 2 == 0;
            if on_ridge && !gap { 32 } else { 224 }
        })
        .collect()
}

// Enroll one capture, then take a second capture of the same finger as the probe.
let frame = synthetic_frame();
let img = GrayImage::new(&frame, 128, 128, 500).expect("buffer holds the image");
let enrolled = template_from_images(&[img]);

let frame2 = synthetic_frame();
let scan = GrayImage::new(&frame2, 128, 128, 500).expect("buffer holds the image");
let scanned = template_from_images(&[scan]);

// Verify (1:1): a bool decision against a driver threshold, or read the raw score.
let threshold = 40;
let _accepted: bool = nbis_verify(&enrolled, &scanned, threshold);
let score: Option<u32> = nbis_match_score(&enrolled, &scanned).score();

// A same-finger recapture out-scores an unrelated print; the caller picks the accept threshold.
let stranger = template_from_images(&[]);
assert!(score >= nbis_match_score(&enrolled, &stranger).score());

// Identify (1:N): the gallery index whose enrolled template best matches the probe.
let gallery = vec![enrolled, stranger];
assert_eq!(nbis_identify(&scanned, &gallery, 0), Some(0));

§Persistence

This crate stops at the in-memory Template. To write an enrolled print to disk in the format libfprint reads and writes, add fprint-fp3 and call its to_bytes / from_bytes on a Print carrying the template — persistence is a separate, single-purpose crate.

Re-exports§

pub use fprint_bozorth3;
pub use fprint_core;
pub use fprint_mindtct;

Modules§

prelude
The handful of names the common path uses: the pipeline functions, the GrayImage input, and the domain Print / Template / Minutia the functions produce and consume.

Structs§

GrayImage
An 8-bit grayscale fingerprint image, row-major, one byte per pixel.

Enums§

ImageError
The error GrayImage::new returns when the supplied image cannot be processed by MINDTCT.
MatchScore
The outcome of scoring one template against another.

Constants§

MIN_DETECTABLE_DIM
The smallest image dimension MINDTCT can process, in pixels.

Functions§

extract_minutiae
Detect the minutiae in a captured 8-bit grayscale frame, as fprint_core::Minutias.
minutia_to_core
Convert one MINDTCT fprint_mindtct::Minutia into an fprint_core::Minutia.
minutiae_to_bozorth
Convert a slice of domain fprint_core::Minutia into fprint_bozorth3::Minutias ready to score.
nbis_identify
Identify (1:N): the gallery index whose enrolled template best matches scanned and clears threshold, or None if none does.
nbis_match_score
Score a scanned probe template against an enrolled one.
nbis_verify
Verify (1:1): whether scanned matches enrolled at or above threshold.
template_from_images
Build a host-side fprint_core::Template::Nbis from a set of captured frames.