#hardware #sensor #linux #libfprint #scanner

libfprint-rs

Rust library for accesing fingerprint devices

11 releases

0.2.3 Sep 20, 2024
0.2.2 Jun 12, 2024
0.2.1 Oct 25, 2023
0.2.0 Aug 24, 2023
0.1.11 Jun 30, 2023

#445 in Hardware support


Used in greetd-stub

MIT license

52KB
950 lines

LIBFPRINT-RS

This crate provides a wrapper around the native libfprint library.

Dependencies

This package requires libfprint-2 to be installed in your system alongside libclang and pkg-config

Usage

Add libfprint-rs as a dependency in Cargo.toml

[dependencies]
libfprint-rs = "0.2.3"

Or using cargo

cargo add libfprint-rs

Import the libfprint_rs crate. The starting point for nearly all libfprint-rs functionality is to create a context object. With a context object, you can list devices, open them and execute their functionalities.

use libfprint_rs::FpContext;

fn main() {
    let ctx = FpContext::new();
    let devices = ctx.devices();
    let dev = devices.get(0).unwrap();

    dev.open_sync(None).unwrap();
}

License

Distributed under the MIT License.

Status

Currently libfprint-rs is WIP.


lib.rs:

Rust bindings for libfprint.

This crate provides a wrapper around the libfprint library, which allows you to use fingerprint scanners in your Rust applications.

Enrolling a new fingerprint

use libfprint_rs::{FpContext, FpPrint};

let context = FpContext::new();
let devices = context.get_devices();

let context = FpContext::new();
let devices = context.devices();

let dev = devices.get(0).unwrap();
dev.open_sync(None)?;

let template = FpPrint::new(&dev);
template.set_username("Bruce Banner");

let print = dev.enroll_sync(template, None, None, None::<()>)?;

Verifying a fingerprint

let context = FpContext::new();
let devices = context.devices();

let dev = devices.get(0).unwrap();
dev.open_sync(None)?;

let enrolled_print = load_print_from_file();

let match_res = dev.verify_sync(enrolled_print, None, None, None::<()>, None)?;

For more examples on how to use this crate, please refer to the github oficial repository and the documentation.

Dependencies

~8–11MB
~232K SLoC