aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/GazeFeatures.py13
-rw-r--r--src/argaze/utils/export_tobii_segment_fixations.py20
2 files changed, 22 insertions, 11 deletions
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py
index 6cdca71..e0c3e73 100644
--- a/src/argaze/GazeFeatures.py
+++ b/src/argaze/GazeFeatures.py
@@ -59,6 +59,19 @@ class FixationIdentifier():
def __next__(self):
raise NotImplementedError('__next__() method not implemented')
+ def identify(self):
+
+ fixations = GazeFeatures.TimeStampedFixations()
+
+ for ts, item in self:
+
+ if item == None:
+ continue
+
+ fixations[ts] = item
+
+ return fixations
+
class DispersionBasedFixationIdentifier(FixationIdentifier):
"""Implementation of the I-DT algorithm as described in:
diff --git a/src/argaze/utils/export_tobii_segment_fixations.py b/src/argaze/utils/export_tobii_segment_fixations.py
index f0a8a4d..7fbdf50 100644
--- a/src/argaze/utils/export_tobii_segment_fixations.py
+++ b/src/argaze/utils/export_tobii_segment_fixations.py
@@ -32,11 +32,11 @@ def main():
os.makedirs(os.path.dirname(args.output))
print(f'{os.path.dirname(args.output)} folder created')
- fixations_filepath = f'{args.output}/fixations.json'
+ fixations_filepath = f'{args.output}/fixations.csv'
else:
- fixations_filepath = f'{args.segment_path}/fixations.json'
+ fixations_filepath = f'{args.segment_path}/fixations.csv'
# Load a tobii segment
tobii_segment = TobiiEntities.TobiiSegment(args.segment_path, int(args.time_range[0] * 1000000), int(args.time_range[1] * 1000000) if args.time_range[1] != None else None)
@@ -66,7 +66,7 @@ def main():
# Start fixation identification
fixation_analyser = GazeFeatures.DispersionBasedFixationIdentifier(generic_ts_gaze_positions, args.dispersion_threshold, args.duration_threshold)
- ts_fixations = GazeFeatures.TimeStampedFixations()
+ fixations = GazeFeatures.TimeStampedFixations()
# Initialise progress bar
MiscFeatures.printProgressBar(0, int(tobii_segment_video.get_duration()/1000), prefix = 'Progress:', suffix = 'Complete', length = 100)
@@ -76,18 +76,16 @@ def main():
if item == None:
continue
- if item.get_type() == 'Fixation':
+ fixations[ts] = item
- ts_fixations[ts] = item
+ # Update Progress Bar
+ progress = ts - int(args.time_range[0] * 1000)
+ MiscFeatures.printProgressBar(progress, int(tobii_segment_video.get_duration()/1000), prefix = 'Progress:', suffix = 'Complete', length = 100)
- # Update Progress Bar
- progress = ts - int(args.time_range[0] * 1000)
- MiscFeatures.printProgressBar(progress, int(tobii_segment_video.get_duration()/1000), prefix = 'Progress:', suffix = 'Complete', length = 100)
-
- print(f'\n{len(ts_fixations)} fixations found')
+ print(f'\n{len(fixations)} fixations found')
# Export fixations analysis results
- ts_fixations.export_as_json(fixations_filepath)
+ fixations.export_as_csv(fixations_filepath)
print(f'Fixations saved into {fixations_filepath}')