Added the option to choose custom finger model.
This commit is contained in:
24
src/main.py
24
src/main.py
@ -127,7 +127,8 @@ class fingerprint_app:
|
|||||||
log.print_message("Stl generation in", self.mode, "mode")
|
log.print_message("Stl generation in", self.mode, "mode")
|
||||||
|
|
||||||
# Default values for stl generation parameters
|
# 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
|
# Get mode and model parameters
|
||||||
if self.mode == 'p':
|
if self.mode == 'p':
|
||||||
@ -172,12 +173,14 @@ class fingerprint_app:
|
|||||||
self.args.stl) > 4 else def_val.get("fy")
|
self.args.stl) > 4 else def_val.get("fy")
|
||||||
self.finger_z = float(self.args.stl[5]) if len(
|
self.finger_z = float(self.args.stl[5]) if len(
|
||||||
self.args.stl) > 5 else def_val.get("fz")
|
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:
|
if len(self.args.stl) < 6:
|
||||||
log.print_message(
|
log.print_message(
|
||||||
"Warning: Too few arguments, using some default values")
|
"Warning: Too few arguments, using some default values")
|
||||||
log.print_message("Line height:", self.height_line, "mm, iterations:", self.iter,
|
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:
|
else:
|
||||||
log.error_exit("Unrecognized generation mode")
|
log.error_exit("Unrecognized generation mode")
|
||||||
@ -274,6 +277,8 @@ class fingerprint_app:
|
|||||||
self.make_stl_curved()
|
self.make_stl_curved()
|
||||||
|
|
||||||
elif self.mode == "m":
|
elif self.mode == "m":
|
||||||
|
# Load the finger model
|
||||||
|
self.finger = trimesh.load(self.finger_name)
|
||||||
self.make_stl_map()
|
self.make_stl_map()
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
||||||
@ -381,6 +386,7 @@ class fingerprint_app:
|
|||||||
param_list.append(str(self.finger_x))
|
param_list.append(str(self.finger_x))
|
||||||
param_list.append(str(self.finger_y))
|
param_list.append(str(self.finger_y))
|
||||||
param_list.append(str(self.finger_z))
|
param_list.append(str(self.finger_z))
|
||||||
|
param_list.append(str(self.finger_name))
|
||||||
|
|
||||||
if self.mode == "p":
|
if self.mode == "p":
|
||||||
param_list.append("P")
|
param_list.append("P")
|
||||||
@ -449,7 +455,7 @@ class fingerprint_app:
|
|||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
# TODO: this is very badly written, fix it
|
# 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
|
# add the bottom array
|
||||||
OFFSET = 0.01
|
OFFSET = 0.01
|
||||||
|
|
||||||
@ -649,20 +655,18 @@ class fingerprint_app:
|
|||||||
min_dist_point = img[i][j]
|
min_dist_point = img[i][j]
|
||||||
return min_dist_point
|
return min_dist_point
|
||||||
|
|
||||||
# Load the finger model
|
# Implicitly translate finger model to match middle of the fingerprint
|
||||||
finger = trimesh.load("res/finger-mod.stl")
|
# This can be modified using finger_x, y and z parameters
|
||||||
|
|
||||||
# Implicitly translate it to match middle of the fingerprint
|
|
||||||
# Later this can be modified
|
|
||||||
x = (self.width * px2mm / 2) + self.finger_x
|
x = (self.width * px2mm / 2) + self.finger_x
|
||||||
y = (self.height * px2mm / 2) + self.finger_y
|
y = (self.height * px2mm / 2) + self.finger_y
|
||||||
z = self.finger_z
|
z = self.finger_z
|
||||||
matrix = tmtra.translation_matrix([x, y, 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
|
# 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(
|
vertices, faces = tmrem.subdivide_loop(
|
||||||
finger.vertices, finger.faces, iterations=self.iter)
|
self.finger.vertices, self.finger.faces, iterations=self.iter)
|
||||||
|
|
||||||
# For logging progress
|
# For logging progress
|
||||||
c = 0
|
c = 0
|
||||||
|
@ -80,8 +80,9 @@ def stl_parser():
|
|||||||
finger_x = header_arr[2]
|
finger_x = header_arr[2]
|
||||||
finger_y = header_arr[3]
|
finger_y = header_arr[3]
|
||||||
finger_z = header_arr[4]
|
finger_z = header_arr[4]
|
||||||
|
finger_model = header_arr[5]
|
||||||
arg_string += mode + " " + height_line + \
|
arg_string += mode + " " + height_line + \
|
||||||
" " + iter + " " + finger_x + " " + finger_y + " " + finger_z
|
" " + iter + " " + finger_x + " " + finger_y + " " + finger_z + " " + finger_model
|
||||||
else:
|
else:
|
||||||
# Print unfinished command
|
# Print unfinished command
|
||||||
print(arg_string, file=sys.stdout)
|
print(arg_string, file=sys.stdout)
|
||||||
@ -107,8 +108,9 @@ def stl_parser():
|
|||||||
finger_x = header_arr[2]
|
finger_x = header_arr[2]
|
||||||
finger_y = header_arr[3]
|
finger_y = header_arr[3]
|
||||||
finger_z = header_arr[4]
|
finger_z = header_arr[4]
|
||||||
|
finger_model = header_arr[5]
|
||||||
arg_string += height_line + " " + iter + \
|
arg_string += height_line + " " + iter + \
|
||||||
" " + finger_x + " " + finger_y + " " + finger_z
|
" " + finger_x + " " + finger_y + " " + finger_z + " " + finger_model
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# Print unfinished command
|
# Print unfinished command
|
||||||
|
22
src/test.sh
22
src/test.sh
@ -9,7 +9,7 @@ source .venv/bin/activate
|
|||||||
#----------------------------Configuration------------------------------#
|
#----------------------------Configuration------------------------------#
|
||||||
|
|
||||||
# place all image files to one folder
|
# 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
|
# 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")
|
presets=("ridge")
|
||||||
|
|
||||||
# generate stl files and set generation mode {"planar", "curved", "mapped"}
|
# generate stl files and set generation mode {"planar", "curved", "mapped"}
|
||||||
generate_stl=false
|
generate_stl=true
|
||||||
generate_stl_mode="planar"
|
generate_stl_mode="c"
|
||||||
|
|
||||||
# in 1/10 of milimeters
|
# in 1/10 of milimeters
|
||||||
height_line=2.5
|
height_line=2.2
|
||||||
height_base=2
|
height_base=12
|
||||||
|
|
||||||
curv_x=1.3
|
curv_x=1.3
|
||||||
curv_y=3
|
curv_y=1.8
|
||||||
|
|
||||||
iteration=1
|
iteration=1
|
||||||
finger_x=0
|
finger_x=0
|
||||||
finger_y=0
|
finger_y=0
|
||||||
finger_z=0
|
finger_z=0
|
||||||
|
finger_model="res/finger_backup/finger-mod.stl"
|
||||||
|
|
||||||
|
|
||||||
#----------------------------Application---------------------------#
|
#----------------------------Application---------------------------#
|
||||||
|
|
||||||
@ -65,14 +67,14 @@ apply_filter() {
|
|||||||
out="${in%%${match1}*}_mod${match1}$format"
|
out="${in%%${match1}*}_mod${match1}$format"
|
||||||
fi
|
fi
|
||||||
case "$generate_stl_mode" in
|
case "$generate_stl_mode" in
|
||||||
"planar")
|
"p")
|
||||||
python3 $exec_path $in $out $dpi -c $config_file $1 --stl p $height_line $height_base || break
|
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
|
python3 $exec_path $in $out $dpi -c $config_file $1 --stl c $height_line $height_base $curv_x $curv_y || break
|
||||||
;;
|
;;
|
||||||
"mapped")
|
"m")
|
||||||
python3 $exec_path $in $out $dpi -c $config_file $1 --stl m $height_line $height_base $fp_file|| break
|
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"
|
echo "SCRIPT: Invalid stl generation mode"
|
||||||
|
Reference in New Issue
Block a user