Skip to main content

Python bindings for NBIS fingerprint processing using Rust + UniFFI

Project description

NBIS-rs

CI

This is a Rust binding to the NIST Biometric Image Software (NBIS) library, which is used for processing biometric images, particularly in the context of fingerprint recognition.

Features

  • Bindings to NBIS functions for minutia extraction, and matching
  • Exports minutiae templates in ISO/IEC 19794-2:2005 format
  • Matches minutiae templates against each other using the NBIS Bozorth3 algorithm

Installation

To use NBIS-rs, add the following to your Cargo.toml:

[dependencies]
nbis = "0.1"

Usage

Here's a simple example of how to use NBIS-rs in your project:

fn main() -> Result<(), Box<dyn std::error::Error>> {
    use nbis;
    use nbis::Minutiae;

    // Read the bytes from a file (you could also use nbis::extract_minutiae_from_image_file)
    // but here we just load the image bytes as image paths on mobile platforms can be tricky.
    let image_bytes = std::fs::read("test_data/p1/p1_1.png")?;
    let minutiae_1 = nbis::extract_minutiae(&image_bytes, None)?;

    let image_bytes = std::fs::read("test_data/p1/p1_2.png")?;
    let minutiae_2 = nbis::extract_minutiae(&image_bytes, None)?;

    let image_bytes = std::fs::read("test_data/p1/p1_3.png")?;
    let minutiae_3 = nbis::extract_minutiae(&image_bytes, None)?;

    // Compare the two sets of minutiae
    let score = minutiae_1.compare(&minutiae_2);
    assert!(score > 50, "Expected a high similarity score between p1_1 and p1_2");
    let score = minutiae_1.compare(&minutiae_3);
    assert!(score > 50, "Expected a high similarity score between p1_1 and p1_3");
    let score = minutiae_2.compare(&minutiae_3);
    assert!(score > 50, "Expected a high similarity score between p1_2 and p1_3");

    // Next we will demonstrate conversion to ISO/IEC 19794-2:2005 format
    // and back to a `Minutiae` object.
    // First, convert the minutiae to ISO template bytes
    let iso_template: Vec<u8> = minutiae_1.to_iso_19794_2_2005();
    // And load it back
    let minutiae_from_iso = nbis::load_iso_19794_2_2005(&iso_template)?;
    // Compare the original minutiae with the one loaded from ISO template
    for (a, b) in minutiae_from_iso.get().iter().zip(minutiae_1.get().iter()) {
        assert_eq!(a.x(), b.x());
        assert_eq!(a.y(), b.y());
        assert_eq!(a.angle(), b.angle());
        assert_eq!(a.kind(), b.kind());
        // Reliability is quantized in the round-trip conversion,
        // so we allow a small margin of error.
        assert!((a.reliability() - b.reliability()).abs() < 1e-1);
    }

    // Finally we demonstrate loading from a file and comparing a negative match
    let minutiae_4 = nbis::extract_minutiae_from_image_file("test_data/p2/p2_1.png", None)?;
    let score = minutiae_1.compare(&minutiae_4);
    assert!(score < 50, "Expected a low similarity score between p1_1 and p2_1");

    Ok(())
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nbis_py-0.1.1-py3-none-manylinux_2_34_x86_64.whl (1.2 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

nbis_py-0.1.1-py3-none-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file nbis_py-0.1.1-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for nbis_py-0.1.1-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1c59fb7364d0f6fc544cb2d15d9d42f8ca41eeab1dd3d72099e96d6eba1239ce
MD5 9cb6fb6eefc631cb666876b2db046b01
BLAKE2b-256 49821699e2234ffbc209cd20e3df8050a23335fe4a823911c5b3525a17988a9d

See more details on using hashes here.

File details

Details for the file nbis_py-0.1.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nbis_py-0.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 45492c6faf407ef6e65342128f4c50c51d9bf0f03febba247cb9744fdfb56cf7
MD5 d578d310da902de8c9466ea016692f15
BLAKE2b-256 89736501c6159f35ccb965c0b5f3d50cef61691db64db552afc92732c9c663d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page