blob: f62487392fc67aab39b97be67c7985e384f88a91 (
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
|
"""
motion_capture/filter.py
Custom signal filter: convert pixel coordinates to millimetres.
Usage in Signals → Channels pipeline:
type: pixel_to_mm
px_per_mm: <calibration value> pixels per millimetre
Calibration: measure a known distance on-screen (e.g. a ruler in frame)
and count how many pixels it spans. Divide pixels by mm → px_per_mm.
"""
from core.signal_processor import FilterBase
class PixelToMMFilter(FilterBase):
"""
y = (x - zero_px) / px_per_mm
Converts pixel position to millimetres. Optionally zero at a reference
point (useful when origin matters more than absolute position).
"""
name = "pixel_to_mm"
def __init__(self, px_per_mm: float = 10.0, zero_px: float = 0.0):
self.params = {"px_per_mm": px_per_mm, "zero_px": zero_px}
def __call__(self, value: float) -> float:
return (value - self.params["zero_px"]) / max(self.params["px_per_mm"], 1e-9)
def reset(self):
pass
|