|
|
@ -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
|
|
|
|