Skip to content

Commit

Permalink
Don't crash on norm_pos == None data from pl_rec_export
Browse files Browse the repository at this point in the history
  • Loading branch information
domstoppable committed Aug 26, 2024
1 parent fb092e7 commit c48b729
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion pupil_src/shared_modules/surface_tracker/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ def map_gaze_and_fixation_events(self, events, camera_model, trans_matrix=None):
results = []
for event in events:
gaze_norm_pos = event["norm_pos"]
if gaze_norm_pos is None:
continue

gaze_img_point = methods.denormalize(
gaze_norm_pos, camera_model.resolution, flip_y=True
)
Expand All @@ -270,7 +273,7 @@ def map_gaze_and_fixation_events(self, events, camera_model, trans_matrix=None):
copy_keys = ["id", "duration", "start timestamp [ns]", "end timestamp [ns]", "duration [ms]"]
else:
copy_keys = ["confidence", "timestamp_unix"]

for key in copy_keys:
mapped_datum[key] = event[key]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,12 @@ def on_notify(self, notification):
fixation_data = [datum.copy() for datum in self.g_pool.fixations]

for fixation_event in fixation_data:
offset = self.get_gaze_offset_plugin().get_manual_correction_for_frame(fixation_event["mid_frame_index"])
fixation_event['norm_pos'] = (
fixation_event['norm_pos'][0] + offset[0],
fixation_event['norm_pos'][1] + offset[1],
)
if fixation_event['norm_pos'] is not None:
offset = self.get_gaze_offset_plugin().get_manual_correction_for_frame(fixation_event["mid_frame_index"])
fixation_event['norm_pos'] = (
fixation_event['norm_pos'][0] + offset[0],
fixation_event['norm_pos'][1] + offset[1],
)

corrected_fixations = pm.Affiliator(fixation_data, self.g_pool.fixations.data_ts, self.g_pool.fixations.stop_ts)

Expand Down

0 comments on commit c48b729

Please sign in to comment.