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