summaryrefslogtreecommitdiff
path: root/plugins/motion_capture/device.py
diff options
context:
space:
mode:
authorChristian Kolset <christian.kolset@gmail.com>2026-06-09 18:47:49 -0600
committerChristian Kolset <christian.kolset@gmail.com>2026-06-09 18:47:49 -0600
commit898fde4dc286517cb27590b2f9cd7406d9922bd4 (patch)
tree02abc27a4c7e3434a171a8250a4728265b693860 /plugins/motion_capture/device.py
parent17b2f07545b89487c2d1bb936dc52a612d38d470 (diff)
Upgrade motion capture: template matching, frame-freeze selection, resolution
Tracking: - Add "template" mode (default) using snapshot + shape-masked matchTemplate - Add "csrt" mode as alternative for texture-rich targets - set_roi_rect(x, y, w, h, frame_rgb) initialises from exact selection rect - set_roi() delegates to set_roi_rect (centred square, backwards-compat) - start() accepts resolution=(w, h) to set camera capture resolution Selection UX: - Replace QLabel feed with FrameSelector widget (custom QWidget) - "Click to Track" freezes frame; user scrolls to zoom (anchored to cursor), right-drags to pan, left-drags to draw rubber-band selection - Shape preview: rectangle or inscribed ellipse depending on mode - "Confirm Selection" extracts template from frozen frame and starts tracking - "Clear" cancels selection or clears active tracking Configuration: - CameraPanel adds Resolution combo (Default / 640×480 / 720p / 1080p / 1440p) - CameraDevice stores and forwards resolution to tracker.start() - Template Match listed first in Mode combo; shape combo hidden for CSRT Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'plugins/motion_capture/device.py')
-rw-r--r--plugins/motion_capture/device.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/motion_capture/device.py b/plugins/motion_capture/device.py
index 9806030..8eb1591 100644
--- a/plugins/motion_capture/device.py
+++ b/plugins/motion_capture/device.py
@@ -26,7 +26,8 @@ class CameraDevice(BaseDevice):
def __init__(self, device_id: str = "cam_0",
camera_index: int = 0,
- simulate: bool = False):
+ simulate: bool = False,
+ resolution=None):
name = "Camera (Sim)" if simulate else f"Camera {camera_index}"
super().__init__(DeviceInfo(
device_id = device_id,
@@ -55,6 +56,7 @@ class CameraDevice(BaseDevice):
))
self._camera_index = camera_index
self._simulate = simulate
+ self._resolution = resolution
self._tracker: Optional[Any] = None
self._tracking_win = None
@@ -63,7 +65,10 @@ class CameraDevice(BaseDevice):
def connect(self) -> bool:
from tracker import CameraTracker
self._tracker = CameraTracker()
- self._tracker.start(-1 if self._simulate else self._camera_index)
+ self._tracker.start(
+ -1 if self._simulate else self._camera_index,
+ resolution=self._resolution,
+ )
if self._tracker.simulated:
self.status = DeviceStatus.SIMULATED
else: