3d_accuracy.py 954 B

1234567891011121314151617181920212223242526272829303132333435
  1. import csv
  2. import os
  3. import numpy as np
  4. sum_distance_joints = np.zeros(18)
  5. counter = 0
  6. def vector_string_to_float(vector):
  7. """
  8. Convert vector string to float
  9. Parameters:
  10. vector: vector still in string
  11. Returns:
  12. vector: vector with type float
  13. """
  14. vector = vector.split(';')
  15. vector = list(map(float, vector))
  16. return vector
  17. path = os.path.join(os.getcwd(), 'Assets\\demo_and_body_positions.csv')
  18. with open(path, newline='') as csvfile:
  19. reader = csv.reader(csvfile)
  20. header = next(reader)
  21. for row in reader:
  22. for i in range(18):
  23. demo = vector_string_to_float(row[i])
  24. body = vector_string_to_float(row[i+18])
  25. distance = np.linalg.norm(np.subtract(demo, body))
  26. sum_distance_joints[i] += distance
  27. counter += 1
  28. for i in range(sum_distance_joints.size):
  29. print("3d accuracy ", header[i][5:], ": ", sum_distance_joints[i] / counter)