Python bindings for NBioBSP using C++ and pybind11
Project description
NBioBSP for Python
Beta module for integrating NBioBSP SDK with Python
This is a Python module for NBioBSP SDK. Built with C/C++ and pybind11. Works only on Windows at the moment.
All code is self contained into a single file, as it is just bindings.
- Documento em Português
Requirements
- Python 3.10 or higher
- eNBSP SDK greater or equal to 5.2
- MSVC 2019 or higher (maybe it works with another compiler, didn't test it yet)
- Cmake 20 or higher
To Do:
- Readable error output using NBioAPI types (priority)
- Handle errors properly
- Throw translatable and proper exceptions from C++ to Python
- Handle return values properly (priority)
- Handle fingerprint purposes on capture properly
- Implement IndexSearch methods
- Implement all functions that are possible in Windows
- Implement all functions that are possible in Linux (no priority)
You can test the module with the following code on the Python interpreter:
import nbsp_python as nbsp
# Initialize the NBioBSP instance
nbsp.initialize_handle()
# Get the version of the NBioBSP SDK
nbsp.get_version()
# Enumerate the devices connected to the computer
nbsp.enumerate_device()
# Open the device using auto-detection
nbsp.open_device()
# Capture a fingerprint and assign it to handle
handle = nbsp.capture("enroll", 10000)
# Verify fingerprints contained in handle
nbsp.verify(handle)
# Extract the hash from the last fingerprint added in the handle
fingerprint_hash = nbsp.extract_fir_text(handle)
# Initialize the index search
nbsp.init_index_search()
# Add the fingerprint to the index search and pass
nbsp.add_fir_to_index_search(fingerprint_hash, 1)
# Identify the fingerprint in the index search
nbsp.identify_data_from_index_search(fingerprint_hash)
# Terminate the index search
nbsp.terminate_index_search()
# Terminate the NBioBSP instance
nbsp.terminate_handle()
# Close the device
nbsp.close_device()
Or by executing a TKinter Example with Python.
Installation
git clone https://github.com/Andoreatta/nbsp-python.git
cd nbsp-python
pip install .
Pulls all the dependencies and installs the module, if something happens, check if the dependencies in pyproject.toml are installed correctly.
Usage
-
nbsp.initialize_handle()
Initializes the NBioBSP instance. Must be called before any other function that interacts with the device. So you can callget_version()
beforeinitialize_handle()
, but notcapture()
. Returns a handle just in case. -
nbsp.terminate_handle()
Terminates the NBioBSP instance. -
nbsp.get_version()
Returns the version of the NBioBSP SDK. -
nbsp.enumerate_device()
Enumerates the devices connected to the computer. Returns a list of devices. -
nbsp.open_device()
Opens the device using auto-detection. Returns the handle of the device. -
nbsp.open_specific_device(index)
Opens the device using the device ID. Returns true if successful. -
nbsp.close_device()
Closes the device. -
nbsp.capture("purpose", timeout)
Captures a fingerprint. Returns the handle of the fingerprint.purpose
can be one of the following:"enroll"
for registering a fingerprint"verify"
for verifying a fingerprint"identify"
for identifying a fingerprint (deprecated as of 5.2)"enroll_for_verification"
for registering a fingerprint for verification"enroll_for_identification"
for registering a fingerprint for identification Thetimeout
parameter is the maximum time in milliseconds to wait for a fingerprint to be captured.
-
nbsp.verify(handle)
Verifies the last fingerprint added in handle. Returns true if successful. -
nbsp.extract_fir_text(handle)
Extracts the fingerprint hash from the handle. Returns the fingerprint hash. -
nbsp.init_index_search()
Initializes the index search. -
nbsp.terminate_index_search()
Terminates the index search. -
nbsp.add_fir_to_index_search(fingerprint_hash, user_id)
Adds a fingerprint to the index search. Returns true if successful.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for nbsp_python-1.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7ef806e5e3161ea354bbff6cc631431504153bb2d8f8cc8a79d2ee67bb3201f |
|
MD5 | 9bff60ac6ff0a9aa39f9ecde45ce6827 |
|
BLAKE2b-256 | 3b470cd209a67adc38e5c34e29e2f98fd61870542885804a2e8224021eadb455 |
Hashes for nbsp_python-1.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b37203c34345f304f0dee3665297f71bc518afbad0e3e12379b8677289a29040 |
|
MD5 | ab96ff8bba495a036973a4fe8dd1a540 |
|
BLAKE2b-256 | 685580aff9cdc87da486a501ae422093a738417ed92f435d0c147076e9465032 |