Added the option to choose custom finger model.

master
Rostislav Lán 2 years ago
parent 73dc3722d7
commit 54435a02e4

@ -127,7 +127,8 @@ class fingerprint_app:
log.print_message("Stl generation in", self.mode, "mode")
# Default values for stl generation parameters
def_val = {"hl": 2, "hb": 10, "crx": 2, "cry": 2, "it": 2, "fx": 0, "fy": 0, "fz": 0}
def_val = {"hl": 2, "hb": 10, "crx": 2, "cry": 2, "it": 2,
"fx": 0, "fy": 0, "fz": 0, "f": "res/finger_backup/finger-mod.stl"}
# Get mode and model parameters
if self.mode == 'p':
@ -172,12 +173,14 @@ class fingerprint_app:
self.args.stl) > 4 else def_val.get("fy")
self.finger_z = float(self.args.stl[5]) if len(
self.args.stl) > 5 else def_val.get("fz")
self.finger_name = str(self.args.stl[6]) if len(
self.args.stl) > 6 else def_val.get("f")
if len(self.args.stl) < 6:
log.print_message(
"Warning: Too few arguments, using some default values")
log.print_message("Line height:", self.height_line, "mm, iterations:", self.iter,
", finger position:", self.finger_x, self.finger_y, self.finger_z)
", finger position:", self.finger_x, self.finger_y, self.finger_z, "mm, finger model:", self.finger_name)
else:
log.error_exit("Unrecognized generation mode")
@ -274,6 +277,8 @@ class fingerprint_app:
self.make_stl_curved()
elif self.mode == "m":
# Load the finger model
self.finger = trimesh.load(self.finger_name)
self.make_stl_map()
plt.show()
@ -381,6 +386,7 @@ class fingerprint_app:
param_list.append(str(self.finger_x))
param_list.append(str(self.finger_y))
param_list.append(str(self.finger_z))
param_list.append(str(self.finger_name))
if self.mode == "p":
param_list.append("P")
@ -449,7 +455,7 @@ class fingerprint_app:
plt.close()
# TODO: this is very badly written, fix it
# TODO: this does not always work, fix it
# TODO: this sometimes generates invalid mesh, fix it
# add the bottom array
OFFSET = 0.01
@ -649,20 +655,18 @@ class fingerprint_app:
min_dist_point = img[i][j]
return min_dist_point
# Load the finger model
finger = trimesh.load("res/finger-mod.stl")
# Implicitly translate it to match middle of the fingerprint
# Later this can be modified
# Implicitly translate finger model to match middle of the fingerprint
# This can be modified using finger_x, y and z parameters
x = (self.width * px2mm / 2) + self.finger_x
y = (self.height * px2mm / 2) + self.finger_y
z = self.finger_z
matrix = tmtra.translation_matrix([x, y, z])
finger.apply_transform(matrix)
self.finger.apply_transform(matrix)
# Subdivide the finger mesh to allow for more precision
# This can be skipped if the model is already dense enough
vertices, faces = tmrem.subdivide_loop(
finger.vertices, finger.faces, iterations=self.iter)
self.finger.vertices, self.finger.faces, iterations=self.iter)
# For logging progress
c = 0

@ -80,8 +80,9 @@ def stl_parser():
finger_x = header_arr[2]
finger_y = header_arr[3]
finger_z = header_arr[4]
finger_model = header_arr[5]
arg_string += mode + " " + height_line + \
" " + iter + " " + finger_x + " " + finger_y + " " + finger_z
" " + iter + " " + finger_x + " " + finger_y + " " + finger_z + " " + finger_model
else:
# Print unfinished command
print(arg_string, file=sys.stdout)
@ -107,8 +108,9 @@ def stl_parser():
finger_x = header_arr[2]
finger_y = header_arr[3]
finger_z = header_arr[4]
finger_model = header_arr[5]
arg_string += height_line + " " + iter + \
" " + finger_x + " " + finger_y + " " + finger_z
" " + finger_x + " " + finger_y + " " + finger_z + " " + finger_model
pass
else:
# Print unfinished command

@ -9,7 +9,7 @@ source .venv/bin/activate
#----------------------------Configuration------------------------------#
# place all image files to one folder
input_path=res/test
input_path=res/test/Jenetrics/leva
# !!!!!!!!!!!!!!!!!!
# this is very important, run this on directories containing files with the same dpi
@ -26,20 +26,22 @@ config_file=conf/conf.json
presets=("ridge")
# generate stl files and set generation mode {"planar", "curved", "mapped"}
generate_stl=false
generate_stl_mode="planar"
generate_stl=true
generate_stl_mode="c"
# in 1/10 of milimeters
height_line=2.5
height_base=2
height_line=2.2
height_base=12
curv_x=1.3
curv_y=3
curv_y=1.8
iteration=1
finger_x=0
finger_y=0
finger_z=0
finger_model="res/finger_backup/finger-mod.stl"
#----------------------------Application---------------------------#
@ -65,14 +67,14 @@ apply_filter() {
out="${in%%${match1}*}_mod${match1}$format"
fi
case "$generate_stl_mode" in
"planar")
"p")
python3 $exec_path $in $out $dpi -c $config_file $1 --stl p $height_line $height_base || break
;;
"curved")
"c")
python3 $exec_path $in $out $dpi -c $config_file $1 --stl c $height_line $height_base $curv_x $curv_y || break
;;
"mapped")
python3 $exec_path $in $out $dpi -c $config_file $1 --stl m $height_line $height_base $fp_file|| break
"m")
python3 $exec_path $in $out $dpi -c $config_file $1 --stl m $height_line $iteration $finger_x $finger_y $finger_z $finger_model|| break
;;
*)
echo "SCRIPT: Invalid stl generation mode"

Loading…
Cancel
Save