fix path errors
This commit is contained in:
@@ -76,11 +76,37 @@ def _bgr_from_gray_or_bgr(img: np.ndarray) -> np.ndarray:
|
||||
return img
|
||||
|
||||
|
||||
def _resolve_calibration_sensor_name(config_name) -> str | None:
|
||||
"""Map a config path/name to a sensors/<name> bundle when one exists."""
|
||||
if config_name is None:
|
||||
return None
|
||||
from orisys.configs import resolve_sensor_bundle
|
||||
|
||||
text = str(config_name).strip()
|
||||
if not text:
|
||||
return None
|
||||
|
||||
path = Path(text)
|
||||
parts = path.parts
|
||||
if "sensors" in parts:
|
||||
idx = parts.index("sensors")
|
||||
if idx + 1 < len(parts):
|
||||
candidate = parts[idx + 1]
|
||||
if resolve_sensor_bundle(candidate) is not None:
|
||||
return candidate
|
||||
|
||||
stem = path.stem if path.suffix else text
|
||||
if resolve_sensor_bundle(stem) is not None:
|
||||
return stem
|
||||
return None
|
||||
|
||||
|
||||
def _snapshot_from_sensor(
|
||||
sensor,
|
||||
*,
|
||||
raw_image=None,
|
||||
processed_image=None,
|
||||
sensor_name: str | None = None,
|
||||
) -> Optional[FrameSnapshot]:
|
||||
"""Build a FrameSnapshot with HHD/forces refreshed every frame."""
|
||||
if sensor is None or sensor.img is None:
|
||||
@@ -124,6 +150,9 @@ def _snapshot_from_sensor(
|
||||
below_threshold_color=(160, 160, 160),
|
||||
)
|
||||
|
||||
cal_name = sensor_name or _resolve_calibration_sensor_name(
|
||||
getattr(sensor, "config_name", None)
|
||||
)
|
||||
fn_raw = float(fnormal)
|
||||
return FrameSnapshot(
|
||||
image=image_bgr,
|
||||
@@ -134,7 +163,7 @@ def _snapshot_from_sensor(
|
||||
normal_force=fn_raw,
|
||||
shear_x=float(fshearx),
|
||||
shear_y=float(fsheary),
|
||||
normal_force_calibrated=calibrate_normal_force(fn_raw),
|
||||
normal_force_calibrated=calibrate_normal_force(fn_raw, sensor_name=cal_name),
|
||||
fps=float(fps),
|
||||
timestamp=time.time(),
|
||||
raw_image=raw_image,
|
||||
@@ -198,6 +227,7 @@ class OrisysSensorAdapter(SensorAdapter):
|
||||
if self.sensor.frame is not None
|
||||
else None,
|
||||
processed_image=_bgr_from_gray_or_bgr(self.sensor.img),
|
||||
sensor_name=_resolve_calibration_sensor_name(self.config_name),
|
||||
)
|
||||
|
||||
def reset(self) -> None:
|
||||
@@ -274,6 +304,7 @@ class Dd06RoiAdapter(SensorAdapter):
|
||||
self.sensor,
|
||||
raw_image=frame,
|
||||
processed_image=rectified,
|
||||
sensor_name=_resolve_calibration_sensor_name(self.config_name),
|
||||
)
|
||||
|
||||
def reset(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user