1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import csv
- import os
- import numpy as np
- 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
- Parameters:
- 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, 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')
- 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
- for i in range(sum_distance_joints.size):
- print("3d accuracy ", header[i][5:], ": ",
- sum_distance_joints[i] / counter)
|