Skip to content

Commit

Permalink
Bugfix in exporting recs with filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
ddetommaso committed Jul 16, 2020
1 parent 849b62a commit 2eb771e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions tobiiglasses/aoi/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import numpy as np
import cv2
import bisect
import os
import matplotlib.path as mplPath
from tobiiglasses.aoi.heatmaps import Heatmap

Expand Down Expand Up @@ -119,12 +120,12 @@ def getAOI(self, ts, gaze_x, gaze_y):
return aoi_id
return None

def exportHeatmap(self):
def exportHeatmap(self, filepath='.'):
H = Heatmap()
for aoi_id, aoi_item in self.__aoi_items__.items():
rows, cols, ch = aoi_item.snapshot.shape
dispsize = (int(cols), int(rows))
H.draw( list(self.__aoi_hits__[aoi_id].values()), dispsize, aoi_item.snapshot_filename, savefilename=('%s_%s.png' % ('heatmap', aoi_id)) )
H.draw( list(self.__aoi_hits__[aoi_id].values()), dispsize, aoi_item.snapshot_filename, savefilename=(os.path.join(filepath, '%s_%s.png') % ('heatmap', aoi_id)) )

def showLandmarks(self, opencvMat, landmarks, color=(0, 0, 255)):
for (x,y) in landmarks:
Expand Down
6 changes: 3 additions & 3 deletions tobiiglasses/recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __getSegmentIDs__(self, segment_id=None):
def __loadSegmentIDs__(self):
self.__segment_ids__.extend(range(1, self.__recording__.getSegmentsN() + 1))

def exportFull(self, fixation_filter, filepath=None, csv_filename='output.csv', video_filename='output.avi', segment_id=1, aoi_models=[]):
def exportFull(self, fixation_filter, filepath='.', csv_filename='output.csv', video_filename='output.avi', segment_id=1, aoi_models=[]):
fixations = self.getFixations(fixation_filter, ts_filter=None, segment_id=segment_id)
logging.info('Exporting video with mapped fixations in folder %s' % filepath)
data = self.getGazeData(segment_id)
Expand All @@ -79,7 +79,7 @@ def exportFull(self, fixation_filter, filepath=None, csv_filename='output.csv',
cap = cv2.VideoCapture(f)
framesAndGaze = iter(VideoFramesAndMappedGaze(data, cap, fps))
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter(video_filename,fourcc, fps, (width,height))
out = cv2.VideoWriter(os.path.join(filepath, video_filename),fourcc, fps, (width,height))


for frame, x, y, ts in framesAndGaze:
Expand Down Expand Up @@ -112,7 +112,7 @@ def exportFull(self, fixation_filter, filepath=None, csv_filename='output.csv',
aoi_id = model.getAOI(ts, fx, fy)
if model.contains(ts, aoi_id, fx, fy):
fixations.setAOI(ts, 0, 0, aoi_id, 100)
model.exportHeatmap()
model.exportHeatmap(filepath)

(filepath, filename) = self.__getFileParams__('csv', segment_id, filepath, csv_filename, 'Fixations')
fixations.exportCSV(filepath, filename, ts_filter=None)
Expand Down

0 comments on commit 2eb771e

Please sign in to comment.