NFIQ2 supports two modes for loading Random Forest model parameters: runtime loading from a file, or embedding directly into the compiled library. This guide covers how to embed models for simplified deployment.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/usnistgov/NFIQ2/llms.txt
Use this file to discover all available pages before exploring further.
Overview
By default, NFIQ2 requires you to load Random Forest model parameters from an external file (e.g.,nist_plain_tir-ink.txt) at runtime. However, you can embed these parameters directly into the library at build time using the EMBED_RANDOM_FOREST_PARAMETERS CMake option.
Benefits of Embedding
Simplified Deployment
No need to distribute separate model files alongside your application
Reduced Errors
Eliminates runtime errors from missing or incorrect model files
Faster Initialization
Skip file I/O during model loading
Single Binary
Everything needed is contained in one executable or library
Trade-offs
Building with Embedded Parameters
CMake Configuration
The embedding is controlled by CMake options inCMakeLists.txt:
Build Steps
Configure CMake with Embedding Enabled
Enable the embedding option when configuring your build:Optionally specify a different FRCT code:
The default FRCT code is “0”, which corresponds to the standard NIST model for plain impressions.
Build the Project
Compile NFIQ2 with the embedded parameters:During compilation, the model parameters will be embedded into the library.
Using Embedded Models
When the model is embedded, your application code becomes simpler:Conditional Compilation
Write code that works with both embedded and runtime-loaded models:NFIQ2_EMBEDDED_MODEL preprocessor macro is defined automatically when embedding is enabled.
Checking if Model is Embedded
At runtime, check if a model is embedded:FRCT Codes
TheEMBEDDED_RANDOM_FOREST_PARAMETER_FCT option specifies which friction ridge capture technology model to embed:
| FRCT Code | Description | Model File |
|---|---|---|
| 0 | Plain impression (default) | nist_plain_tir-ink.txt |
| 2 | Rolled impression | Contact NIST for model |
Most applications should use FRCT code 0 (plain impressions). Other codes are for specialized capture scenarios.
Build Examples
Standard Embedded Build
Cross-Platform Build Script
Example Application Makefile
If you’re building an application against an installed NFIQ2 library:Distribution Considerations
With Embedded Model
✅ Advantages:- Single executable/library to distribute
- No external files required
- Guaranteed model version
- Larger binary size (~500KB increase)
- Model updates require recompilation
- Cannot switch models at runtime
Without Embedded Model
✅ Advantages:- Smaller binaries
- Model updates without recompilation
- Runtime model selection
- Must distribute model files separately
- Potential for missing/wrong model files
- More complex deployment
Best Practices
For End-User Applications
For End-User Applications
Embed the model for simplified distribution and reduced user error. End users shouldn’t need to manage model files.
For Development
For Development
Use runtime loading during development for flexibility. Switch between different models without rebuilding.
For Research
For Research
Use runtime loading to easily test and compare different model versions.
For Libraries
For Libraries
Provide both options: embedded for convenience, runtime loading for flexibility. Use conditional compilation to support both.
Troubleshooting
Model Not Embedded
-DEMBED_RANDOM_FOREST_PARAMETERS=ON and rebuild completely.
Binary Size Concerns
If binary size is critical, use runtime loading:Next Steps
Computing Scores
Learn how to use your compiled library to compute quality scores
Building from Source
Detailed build instructions for all platforms