40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
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)
|
|
|