Skip to content
Snippets Groups Projects
Commit fcfb144c authored by shreyasb's avatar shreyasb
Browse files

PC updates

parent 1eed323c
Branches
No related tags found
No related merge requests found
......@@ -99,7 +99,7 @@ Rigid_body = [[0.9998443871765447, 0.016930978475685435, 0.004954129531717574, 0
[-0.0019197896155425946, -0.1747337675862396, 0.9846138455622852, -0.017384735431967623],
[0., 0., 0., 1.]]
num_apriltags = 12
num_apriltags = 11
# screen1_ids = [32, 31, 3, 5, 10, 7]
# screen2_ids = [33, 30, 17, 6]
# screen3_ids = [9, 2]
......@@ -183,8 +183,8 @@ start = time.time()
num_blinks = 0
while True:
while True:
ret, frame = cap.read()
bg_copy = background.copy()
......@@ -205,7 +205,7 @@ while True:
continue
pd_left = data['left_eye']['pd']['pd']
pd_right = data['right_eye']['pd']['pd']
print(pd_left, pd_right)
# print(pd_left, pd_right)
if len(gaze3) < 4:
gaze3.append(1)
gaze3 = np.array(gaze3)
......@@ -238,9 +238,11 @@ while True:
if H2 is not None:
gaze_mapped_s2 = np.dot(H2, gaze_mapped)
gaze_mapped_s2 = gaze_mapped_s2/gaze_mapped_s2[2]
cv2.circle(s2_copy, (int(gaze_mapped_s2[0]), int(gaze_mapped_s2[1])), 2, (0,0,255), 40)
vec = (gaze_mapped_s2[:2] - err_center)
err.append(vec)
cv2.circle(s2_copy, (int(gaze_mapped_s2[0]), int(gaze_mapped_s2[1])), 2, (255,0,0), 20)
err_center = get_closest(gaze_mapped_s2, err_centers)
if err_center is not None:
vec = (gaze_mapped_s2[:2])# - err_center)
err.append(vec)
# elif gaze_mapped_back[0] > s3_min and gaze_mapped_back[0] < s3_max and gaze_mapped_back[1] > 240:
# H3 = get_hom(result, fix_s3)
......@@ -253,31 +255,27 @@ while True:
cv2.imshow('mapped gaze', bg_copy)
# cv2.imshow("screen1", s1_copy)
cv2.imshow("screen2", s2_copy)
# cv2.imshow("screen3", s3_copy)
elapsed = time.time() - start
# total_elapsed += elapsed
if cv2.waitKey(20) & 0xFF == ord('q'):
if cv2.waitKey(10) & 0xFF == ord('q'):
break
# cv2.imshow("screen3", s3_copy)
# elapsed = time.time() - start
# if elapsed > 20:
# print("Done")
# break
# if elapsed > 20:
# print("Done")
# break
elif pd_left == -1 or pd_right == -1:
num_blinks += 1
dir_name = "error_data/Screen1/multiple/gazedata"
dir_name = "error_data/Screen2_laptop/multiple/gazedata"
if not os.path.exists(dir_name):
os.makedirs(dir_name)
np.save(dir_name + "/data1", err)
np.save(dir_name + "/gaze_data", err)
# np.save(dir_name + "/direct_gaze_1", err)
# np.save(dir_name + "/looking_left_corner_1", err)
# np.save(dir_name + "/looking_right_corner_1", err)
# np.save(dir_name + "/moving_head_1", err)
print()
print("number of blinks", num_blinks)
print()
# print()
# # print("number of blinks", num_blinks)
# print()
tobiiglasses.stop_streaming()
cap.release()
cv2.destroyAllWindows()
......
......@@ -2,9 +2,6 @@ import numpy as np
import matplotlib.pyplot as plt
def avg(data, i, j, n):
# print(data)
......@@ -16,7 +13,7 @@ def remove_outliers(data):
length = data.shape[0]
ret_data = [[],[]]
average_over = 2
threshold = 3
threshold = 5
for i in range(length - average_over):
for j in range(2):
if i in range(average_over):
......@@ -28,11 +25,11 @@ def remove_outliers(data):
return ret_data
data = np.load("error_data/Screen1/multiple/allpos/direct_gaze_1.npy")
data = np.load("error_data/Screen2_laptop/multiple/gazedata/data1.npy")
data = remove_outliers(data)
max_length = 900
max_length = min(1100, len(data[0]), len(data[1]))
x_time = np.zeros((max_length,))
y_time = np.zeros((max_length,))
......@@ -55,6 +52,8 @@ plt.plot(x_time, x_data)
plt.plot(x_time, [x_mean] * max_length, linewidth=3, color='black')
plt.title("Error in mapping x coordinate")
plt.ylabel("Error in gaze x coordinate (percentage)")
# plt.title("Mapped x coordinate")
# plt.ylabel("Mapped x coordinate (pixels)")
plt.xlabel("Time (s)")
plt.figure(1)
......@@ -62,6 +61,8 @@ plt.plot(y_time, y_data)
plt.plot(y_time, [y_mean] * max_length, linewidth=3, color='black')
plt.title("Error in mapping y coordinate")
plt.ylabel("Error in gaze y coordinate (percentage)")
# plt.title("Mapped y coordinate")
# plt.ylabel("Mapped y coordinate (pixels)")
plt.xlabel("Time (s)")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment