This project has been developed as a part of bachelor’s thesis at Brno University of Technology - Faculty of Information Technology. The topic of this thesis was Generating a 3D Fingerprint Model from input fingerprint image.
This application consists of two main parts.The first part of the application uses image filters to enhance fingerprint images. Application also implements a custom filter library, which consists of several filters imported from image processing modules.
The second part uses the processed image to make a 3D model of the fingerprint. The model can then be used to print an accurate representation of human fingerprint using a 3D printer.
The application has only been tested on Ubuntu gnu/linux machines. It should however be possible to use it in on most linux distributions, WSLs and also virtual machines of most linux distributions.
To start off, you need these to succesfully use the application.
python version 3.10 is a requirement might work on earlier python 3 versions:
sudo apt install python3.10
virtualenv package for virtual enviroment creation, other packages are installed automatically later:
pip install virtualenv
This will install the application and its components into the Documents directory. It will also install several required python packages, including venv, which is used to create a virtual enviroment.
Go to a suitable installation folder, for example Documents:
cd /home/username/Documents
Clone the repository to a suitable directory, for example:
git clone ssh://git@strade.fit.vutbr.cz:3022/xlanro00/BP_DP-xlanro00.git
Go inside cloned directory:
cd BP_DP-xlanro00
Create and enter the virtual enviroment:
virtualenv .venv && source .venv/bin/activate
Install required python modules from requirements.txt:
pip install -r requirements.txt
Now, you are all set to run the application. Examples of how to do this are listedin the section bellow.
Once all the requirements are installed, the application is ready to use. Fingerprint sample is located in res/examples, its name is Palec_P4.tif.
You will need to enter the virtual enviroment every time you want to use the application.
source .venv/bin/activate
The application requires input and output filenames including path from the root project directory, dpi and filter list as shown bellow.
python3 src/main.py input_file output_file dpi filters
There are two ways to enter the filters:
manually list all filter names and their parameters on the command line:
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_cline.png 600 total_variation weight=0.15 median ksize=5
load them from preset in a JSON configuration file, that can be used to tune and modify existing presets, or create new ones:
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_preset.png 600 --config conf/conf.json git_example
There is an option to input the filter series as a preset from JSON configuration file. Here the presets are stored and are ready to be used whenever needed. You can usehow many filters you need as long as you like the output. It is therefore highly recommended to check the output after every preset change.
Filter used in the example above is listed bellow, along with the general form of configuration file.
General format | Woking example |
---|---|
|
|
To avoid accidental loss of information caused by modifying presets that have been used to generate stl files, these presets are stored inside a JSON file db.json.
This file serves as a simple database for storing presets, stored presets are modified by adding generated hash of all the filters in that preset. There is also an option to save current command line setting as a preset using -d switch and it’s new name:
Overview of all implemented filters and their parameters with descriptions is listed below.
median blur
gaussian blur
bilateral blur
bilateral_scikit
nlmeans (non-local means)
total_variation
block_match
unsharp mask scikit
farid
meijering
sato
hessian
invert
scale_values
binarize
binarize_otsu
add_margin
erode
dilate
It is possible to generate stl model using the --stl
switch. This requires more parameters, first of which is the type of generated fingerprint.
If the mode is set to c
, the output model will be a curved finger model, with optional parameters following the filename controlling its shape.
First optional parameter is papilar line height height_line
, second is thickness of the model height_base
, third the rate of curvature along x axis curv_rate_x
and the third is the rate of curvature along y axis curv_rate_y
.
General form for curved stl generation:
python3 src/main.py input_file output_file dpi --config config_file preset --stl c height_line height_base curvature_x curvature_y
Working example curved stl generation:
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_preset.png 600 --config config/config.json git_example --stl c 2 10 2 2
Using p
mode makes the generated fingerprint model flat. Optional parameters are height of the papilar lines and base thickness.
General command form for planar stl generation:
python3 src/main.py input_file output_file dpi --config config_file preset --stl p height_line height_base
Working example of planar stl generation:
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4_from_preset.png 600 --config config/config.json git_example --stl p 2 10
Using m
mode modifies the preexisting finger model to contain fingerprint. First optional parameter is papilar line height height_line
, second is the number of iterations iter
to make the finger mesh denser. Higher number of itertions results in denser finger mesh and better result. The last three parameters are axis offsets for the finger, finger_x
, finger_y
, finger_z
. These control the location of the finger. They need to be set only if the user wants to move core of the print closer to the center of the finger.
General command form for mapped stl generation
python3 src/main.py input_file output_file dpi --config config_file preset --stl m height_line iter finger_x finger_y finger_z
Working example of finger mapping
python3 src/main.py res/examples/Palec_P4.tif res/examples/Palec_P4.png 600 --config conf/conf.json ridge --stl m 0.2 2 0 0 0
When in doubt, you can always check the help with:
python3 src/main.py --help
Which will print out the following message.
usage: main.py [-h] [-m | --mirror | --no-mirror] input_file
output_file dpi ([-c | --config config_file preset] |
[filters ...]) [-s | --stl_file p height_line height_base |
--stl_file c height_line height_base curv_rate_x curv_rate_y |
--stl m height_line iter finger_x finger_y finger_z]
[-d | --database database_filename]
Program for processing a 2D image into 3D fingerprint.
positional arguments:
input_file input file path
output_file output file path
dpi dpi of used scanner
filters list of filter names and their parameters in form
[filter_name1 param1=value
param2=value filter_name2 param1=value...]
options:
-h, --help show this help message and exit
-m, --mirror, --no-mirror
switch to mirror input image
-s [STL_FILE ...], --stl_file [STL_FILE ...]
create stl model from processed image
-c CONFIG CONFIG, --config CONFIG CONFIG
pair: name of the config file with presets,
name of the preset
Error message | Solution |
---|---|
main.py: error: the following arguments are required: input_file, output_file, dpi, filters | You probably forgot to include some of the required arguments. |
ERROR: Input file res/Palec_P14.tif does not exist | The file you want to process does not exist, check the filename again. |
ERROR: Config file not found | The config file you want to load config from does not exist, check the filename again. |
ERROR: Preset not found in config file | The preset is not present in selected config file, check the file again or select the correct config file. |
ERROR: Filter undefined_filter not found | One of the filters from command line is not defined in the library, check its name. |
ERROR: Unrecognized generation mode | The first parameter of stl generation should be p, c or m, check it again. |
ERROR: Line depth must be less than plate thickness | When generating a cast, the depth must be less than the base plate thckness, otherwise it would have holes on the other side. |
ERROR: Depth of plate height must be positive | Cannot generate negative base plate thickness, check order of arguments. |
ERROR: Base and line height must both be positive | In curved generation any negative argument is an error, casts are only for planar mode. |