From b776e70b4cd94c5d1f53dde39b2e46f6447cac3e Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Tue, 9 Jun 2026 19:39:35 -0600 Subject: Motion capture: profile support, FPS config, persistent tracking, window state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Profile integration: - CameraDevice.get_save_config() serialises camera_index, simulate, resolution, fps — cameras now persist in .labdaq profiles - ProfileManager.register/unregister_device_factory() lets plugins register their device classes for profile restoration without core → plugin dependency - MotionCapturePlugin registers CameraDevice factory on load/unload Camera configuration: - Add Frame Rate combo to CameraPanel (Default/15/24/30/60/120 fps) defaults to 30 fps; flows through to CAP_PROP_FPS on connect - tracker.start() accepts fps param alongside existing resolution Tracking persistence: - CameraTracker.is_running() — checks thread alive state - MotionCaptureWindow initialises _connected from tracker.is_running() so reopening the window resumes the live feed without restarting the camera or losing the active tracking state Window state: - Plugin saves px_per_mm + camera_idx when window closes - Reopened window restores saved values and syncs mode/shape UI from tracker state via restore_ui_state() (signals blocked to avoid resetting tracker) - Window type changed to Qt.WindowType.Window for independent close button on all Linux WMs Co-Authored-By: Claude Sonnet 4.6 --- plugins/motion_capture/window.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'plugins/motion_capture/window.py') diff --git a/plugins/motion_capture/window.py b/plugins/motion_capture/window.py index bc9a0de..46b8850 100644 --- a/plugins/motion_capture/window.py +++ b/plugins/motion_capture/window.py @@ -245,10 +245,9 @@ class MotionCaptureWindow(QWidget): closed = pyqtSignal() def __init__(self, tracker, parent=None): - super().__init__(parent, Qt.WindowType.Window | Qt.WindowType.Tool) + super().__init__(parent, Qt.WindowType.Window) self._tracker = tracker - self._connected = False - self._selecting = False # True while frame is frozen for selection + self._selecting = False self.setWindowTitle("Motion Capture") self.setMinimumSize(680, 560) @@ -256,6 +255,11 @@ class MotionCaptureWindow(QWidget): self._build() + # Reflect tracker's actual state — it may already be running + self._connected = tracker.is_running() + self._sim_badge.setVisible(self._connected and tracker.simulated) + self._sync_controls() + self._refresh = QTimer(self) self._refresh.timeout.connect(self._update) self._refresh.start(33) @@ -500,6 +504,19 @@ class MotionCaptureWindow(QWidget): # ── State accessors ──────────────────────────────────────────────────── + def restore_ui_state(self, mode: str, shape: str): + """Sync mode/shape UI to tracker state without triggering tracker resets.""" + self._mode_cb.blockSignals(True) + self._shape_cb.blockSignals(True) + self._mode_cb.setCurrentIndex(1 if mode == "csrt" else 0) + self._shape_cb.setCurrentIndex(1 if shape == "circle" else 0) + is_template = mode == "template" + self._shape_lbl.setVisible(is_template) + self._shape_cb.setVisible(is_template) + self._mode_cb.blockSignals(False) + self._shape_cb.blockSignals(False) + self._feed.set_shape(shape) + def get_camera_index(self) -> int: i = self._cam_combo.currentIndex() cameras = getattr(self, "_cameras", []) -- cgit v1.2.3