[eyetracker] new data, updated assignment, part of solution

This commit is contained in:
2021-02-01 10:37:01 +01:00
parent e953a9aacb
commit 56d40404bd
17 changed files with 592 additions and 25 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@@ -0,0 +1,29 @@
import numpy as np
import scipy.io as sp
from IPython import embed
with open('corsi_VP19_eyedata.log') as f:
lines = f.readlines()
eye_found = np.zeros((len(lines)-7,1))
gaze_x = np.zeros(eye_found.shape)
gaze_y = np.zeros(eye_found.shape)
frame_time = np.zeros(eye_found.shape)
marker_time = np.zeros(eye_found.shape)
marker_count = np.zeros(eye_found.shape)
for i in range(7,len(lines)):
line = lines[i].strip().split()
eye_found[i-7] = line[1]
gaze_x[i-7] = line[2]
gaze_y[i-7] = line[3]
frame_time[i-7] = line[10]
marker_time[i-7] = line[11]
marker_count[i-7] = line[9]
to_be_stored = {'eye_found': eye_found, 'gaze_x':gaze_x, 'gaze_y':gaze_y,
'frame_time':frame_time, 'marker_time':marker_time,
'marker_count':marker_count}
sp.savemat('eye_tracking.mat', to_be_stored)

View File

@@ -0,0 +1,39 @@
import numpy as np
import scipy.io as spio
import glob
import os
def export_file(filename):
frame_idx = []
eye_found = []
gaze_x = []
gaze_y = []
marker = []
with open(filename, "r") as f:
for i, line in enumerate(f):
if i < 7:
continue
parts = line.strip().split()
frame_idx.append(int(parts[0]))
eye_found.append(int(parts[1]))
gaze_x.append(int(parts[2]))
gaze_y.append(int(parts[3]))
marker.append(int(parts[-4]))
frame_idx = np.array(frame_idx)
eye_found = np.array(eye_found)
gaze_x = np.array(gaze_x)
gaze_y = np.array(gaze_y)
marker = np.array(marker)
to_be_stored = {'eye_found': eye_found, 'gaze_x':gaze_x, 'gaze_y':gaze_y,
'frame_index':frame_idx, 'marker':marker}
outfile = filename.split(os.sep)[-1].split(".")[0] + ".mat"
spio.savemat(outfile, to_be_stored)
files = sorted(glob.glob(os.path.join(".", "*.log")))
for f in files:
print("exporting: ", f)
export_file(f)