Browse Source

implement plot

Kenkart 2 years ago
parent
commit
21eea1fb3e
1 changed files with 25 additions and 1 deletions
  1. 25 1
      3d_accuracy.py

+ 25 - 1
3d_accuracy.py

@@ -1,6 +1,7 @@
 import csv
 import os
 import numpy as np
+from matplotlib import pyplot as plt
 
 sum_distance_joints = np.zeros(18)
 counter = 0
@@ -17,8 +18,31 @@ def vector_string_to_float(vector):
     vector = vector.split(';')
     vector = list(map(float, vector))
     return vector
+fig, ax = plt.subplots(1,2, sharey=True)
+for root, dir, files in os.walk(os.path.join(os.getcwd(), 'DataCSV\\name\\')):
+	for file in files:
+		if file.endswith(".csv"):
+			path = os.path.join(root, file)
+			with open(path, newline='') as csvfile:
+				reader = csv.reader(csvfile)
+				header = next(reader)
+				for row in reader:
+					for i in range(18):
+						demo = vector_string_to_float(row[i])
+						body = vector_string_to_float(row[i+18])
+						distance = np.linalg.norm(np.subtract(demo, body))
+						sum_distance_joints[i] += distance
+					counter += 1
+			x = [header[i][5:] for i in range(18) ]
+			y = [sum_distance_joints[i] / counter for i in range(18)]
+			if "FirstPerson" in file:
+				ax[0].scatter(x,y, label="1st")
+				ax[0].set_label("1st")
+			else:
+				ax[1].scatter(x,y, label="3rd")
+plt.show()
 
-path = os.path.join(os.getcwd(), 'Assets\\demo_and_body_positions.csv')
+path = os.path.join(os.getcwd(), 'DataCSV\\name\\FirstPersonPerspective_OneArm_Forward_HapticFeedback_Slow.csv')
 with open(path, newline='') as csvfile:
     reader = csv.reader(csvfile)
     header = next(reader)