From 5365582d2caea8c034a28d8ee762c385cad57339 Mon Sep 17 00:00:00 2001 From: Simon Maurer Date: Wed, 18 Dec 2019 18:02:05 +0100 Subject: [PATCH 1/4] small mod to stream position data to zmq --- .../controller/online_controller.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py b/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py index 85027412e4..7319ab3a9c 100644 --- a/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py +++ b/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py @@ -47,6 +47,8 @@ def _on_recent_events(self, events): self._calculate_current_markers(events["frame"]) self._calculate_current_pose(events["frame"]) self._save_key_markers() + events["head_position"] = self._create_position_events( + self._localization_storage.current_pose) def _calculate_current_markers(self, frame): self._detection_storage.current_markers = worker.online_detection(frame) @@ -60,6 +62,17 @@ def _calculate_current_pose(self, frame): self._camera_intrinsics, ) + def _create_position_events(self, current_pose): + """ + Adds position events to the current list of events. + + Args: + current_pose: The current position of the head. + """ + position = {"topic": "head_position"} + position.update(current_pose) + return position + def _save_key_markers(self): if self._general_settings.optimize_markers_3d_model: self._optimization_storage.all_key_markers += pick_key_markers.run( From 81412768816fda27453104ce55d613e1926dca63 Mon Sep 17 00:00:00 2001 From: Simon Maurer Date: Thu, 19 Dec 2019 13:03:33 +0100 Subject: [PATCH 2/4] events must be a list or a tuple --- .../head_pose_tracker/controller/online_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py b/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py index 7319ab3a9c..ddde1fa849 100644 --- a/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py +++ b/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py @@ -71,7 +71,7 @@ def _create_position_events(self, current_pose): """ position = {"topic": "head_position"} position.update(current_pose) - return position + return [position] def _save_key_markers(self): if self._general_settings.optimize_markers_3d_model: From 68559942ec608c17a0982a50b33a0f328a0a6da0 Mon Sep 17 00:00:00 2001 From: Simon Maurer Date: Thu, 19 Dec 2019 13:04:09 +0100 Subject: [PATCH 3/4] change topic name --- .../head_pose_tracker/controller/online_controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py b/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py index ddde1fa849..db594325b3 100644 --- a/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py +++ b/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py @@ -47,7 +47,7 @@ def _on_recent_events(self, events): self._calculate_current_markers(events["frame"]) self._calculate_current_pose(events["frame"]) self._save_key_markers() - events["head_position"] = self._create_position_events( + events["head_pose"] = self._create_position_events( self._localization_storage.current_pose) def _calculate_current_markers(self, frame): @@ -69,7 +69,7 @@ def _create_position_events(self, current_pose): Args: current_pose: The current position of the head. """ - position = {"topic": "head_position"} + position = {"topic": "head_pose"} position.update(current_pose) return [position] From 631e126ce1b0019f77007ebbe08d8adf06f3dee3 Mon Sep 17 00:00:00 2001 From: Simon Maurer Date: Tue, 7 Jan 2020 10:31:01 +0100 Subject: [PATCH 4/4] Addressing change requests - change function `_create_position_events` description - change function `_create_position_events` name to `_create_head_pose_events` - use object attribute directly (instead of passing it by function argument) - apply black formatter --- .../controller/online_controller.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py b/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py index db594325b3..0a4e4506e2 100644 --- a/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py +++ b/pupil_src/shared_modules/head_pose_tracker/controller/online_controller.py @@ -47,8 +47,7 @@ def _on_recent_events(self, events): self._calculate_current_markers(events["frame"]) self._calculate_current_pose(events["frame"]) self._save_key_markers() - events["head_pose"] = self._create_position_events( - self._localization_storage.current_pose) + events["head_pose"] = self._create_head_pose_events() def _calculate_current_markers(self, frame): self._detection_storage.current_markers = worker.online_detection(frame) @@ -62,15 +61,12 @@ def _calculate_current_pose(self, frame): self._camera_intrinsics, ) - def _create_position_events(self, current_pose): + def _create_head_pose_events(self): """ - Adds position events to the current list of events. - - Args: - current_pose: The current position of the head. + Creates head pose events to be added to the current list of events. """ position = {"topic": "head_pose"} - position.update(current_pose) + position.update(self._localization_storage.current_pose) return [position] def _save_key_markers(self):