feat: LEAP velocity blink tweak

This commit is contained in:
Prohurtz 2024-07-22 10:05:05 -05:00
parent c0ac123fde
commit 11f1e68fcc

View File

@ -78,20 +78,27 @@ def run_onnx_model(queues, session, frame):
def calculate_velocity_vectors(old_matrix, current_matrix, time_difference): def calculate_velocity_vectors(old_matrix, current_matrix, time_difference):
# Check if both matrices have the same number of points
if len(old_matrix) != len(current_matrix): if len(old_matrix) != len(current_matrix):
raise ValueError("Both matrices must have the same number of points") raise ValueError("Both matrices must have the same number of points")
# Indices of the points to be considered
indices = [1, 2, 4, 5]
velocity_vectors = [] velocity_vectors = []
for i in range(len(old_matrix)): for i in indices:
old_point = np.array(old_matrix[i]) old_y = old_matrix[i]
current_point = np.array(current_matrix[i]) current_y = current_matrix[i]
displacement = current_point - old_point # Calculate displacement and velocity using the y-values
velocity = displacement / time_difference displacement_y = current_y - old_y
velocity_y = displacement_y / time_difference
velocity_vectors.append(velocity) velocity_vectors.append(velocity_y)
total_velocity = np.mean([np.linalg.norm(vector) for vector in velocity_vectors])
# Calculate the total velocity as the mean of the absolute values of the velocity vectors
total_velocity = np.mean([abs(velocity) for velocity in velocity_vectors])
return total_velocity return total_velocity
@ -297,7 +304,8 @@ class LEAP_C(object):
if per <= 0.25: # TODO: EXPOSE AS SETTING if per <= 0.25: # TODO: EXPOSE AS SETTING
per = 0.0 per = 0.0
if self.total_velocity > 1: print(self.total_velocity)
if self.total_velocity > 1.5:
per = 0.0 per = 0.0
# this should be tuned, i could make this auto calib based on min from a list of per values. # this should be tuned, i could make this auto calib based on min from a list of per values.