Explorar o código

Update 3d_accuracy.py

Kenkart %!s(int64=2) %!d(string=hai) anos
pai
achega
70c0aec914
Modificáronse 1 ficheiros con 41 adicións e 26 borrados
  1. 41 26
      3d_accuracy.py

+ 41 - 26
3d_accuracy.py

@@ -6,6 +6,7 @@ from matplotlib import pyplot as plt
 sum_distance_joints = np.zeros(18)
 counter = 0
 
+
 def vector_string_to_float(vector):
     """
     Convert vector string to float
@@ -14,35 +15,49 @@ def vector_string_to_float(vector):
         vector: vector still in string
     Returns:
         vector: vector with type float
-    """ 
+    """
     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")
+
+
+fig, ax = plt.subplots(1, 3, sharey=True)
+
+for root, dir, files in os.walk(os.path.join(os.getcwd(), 'DataCSV\\Gary\\')):
+    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:
+                sc = ax[0].scatter(x, y)
+                # for i in range(len(x)):
+                #     ax[0].annotate(file[22:], xy=(i,y[i]))
+            if "ThirdPersonPerspective_" in file:
+                ax[1].scatter(x, y)
+            elif "MultipleViews" in file:
+                ax[2].scatter(x, y)
+fig.autofmt_xdate(rotation=45)
+ax[0].set_title('First Person')
+ax[1].set_title('Third Person')
+ax[2].set_title('Third Person Multiple View')
+
+
+# plt.legend(files).set_draggable(True)
 plt.show()
 
-path = os.path.join(os.getcwd(), 'DataCSV\\name\\FirstPersonPerspective_OneArm_Forward_HapticFeedback_Slow.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)
@@ -55,5 +70,5 @@ with open(path, newline='') as csvfile:
         counter += 1
 
 for i in range(sum_distance_joints.size):
-    print("3d accuracy ", header[i][5:], ": ", sum_distance_joints[i] / counter)
-
+    print("3d accuracy ", header[i][5:], ": ",
+          sum_distance_joints[i] / counter)