blob: 6eb55087074c27addaa8bd774b74fa2444cfcb79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
"""
motion_capture/plugin.py
LabDAQ Motion Capture plugin.
When enabled, adds a "Camera" device type to the Add Device dialog.
Each camera added by the user becomes a first-class device in the
acquisition pipeline — data flows through the standard
Device → Signal → Channel → Plot stream.
Custom filter registered globally:
pixel_to_mm — convert pixel coords to mm using a px_per_mm value.
Add it in Signals → Channels on x_pos or y_pos.
Install OpenCV for real camera support:
pip install opencv-python
"""
from __future__ import annotations
from plugins.base_plugin import LabPlugin, PluginContext
class MotionCapturePlugin(LabPlugin):
# ── Metadata ──────────────────────────────────────────────────────────
@property
def plugin_id(self) -> str: return "motion_capture"
@property
def name(self) -> str: return "Motion Capture"
@property
def version(self) -> str: return "1.0.0"
@property
def description(self) -> str:
return (
"Adds a Camera device type to the Add Device dialog. "
"Stream x/y tracking coordinates directly into the signal pipeline."
)
@property
def author(self) -> str: return "LabDAQ"
# ── Lifecycle ─────────────────────────────────────────────────────────
def on_load(self, context: PluginContext) -> None:
self._ctx = context
from ui.add_device_dialog import _PANELS
from camera_panel import CameraPanel
_PANELS["Camera"] = (CameraPanel, "cam")
def on_unload(self) -> None:
from ui.add_device_dialog import _PANELS
_PANELS.pop("Camera", None)
# ── Integration hooks ─────────────────────────────────────────────────
def get_filter_classes(self) -> dict:
from filter import PixelToMMFilter
return {"pixel_to_mm": PixelToMMFilter}
|