3d_accuracy.py 843 B

123456789101112131415161718192021222324252627282930313233
  1. import csv
  2. import os
  3. import numpy as np
  4. sum_distance = 0
  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. 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 += distance
  27. counter += 1
  28. print("3d accuracy: ", sum_distance / counter)