Skip to content

Commit c17e1f2

Browse files
committed
Remove optional transforms from Basler backend
Remove the apply_transforms flag and associated transform logic from dlclivegui/cameras/backends/basler_backend.py. This deletes the _apply_crop helper, the attribute initialization for _apply_transforms, and the code that applied rotation and cropping to captured frames, leaving frames unmodified by the backend. Simplifies the Basler backend by delegating any image transforms to upstream/post-processing.
1 parent 1ea3c3b commit c17e1f2

1 file changed

Lines changed: 0 additions & 30 deletions

File tree

dlclivegui/cameras/backends/basler_backend.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def __init__(self, settings):
3232

3333
# Optional fast-start hint for probe workers (best-effort; doesn't change behavior yet)
3434
self._fast_start: bool = bool(self.ns.get("fast_start", False))
35-
self._apply_transforms: bool = bool(self.ns.get("apply_transforms", False))
3635

3736
# Stable identity (serial-based). Prefer new namespace; fall back to legacy keys read-only.
3837
self._device_id: str | None = None
@@ -314,19 +313,6 @@ def _positive_float(value) -> float | None:
314313
except Exception:
315314
return None
316315

317-
@staticmethod
318-
def _apply_crop(frame: np.ndarray, x0: int, y0: int, x1: int, y1: int) -> np.ndarray:
319-
h, w = frame.shape[:2]
320-
if x1 <= 0:
321-
x1 = w
322-
if y1 <= 0:
323-
y1 = h
324-
x0 = max(0, min(int(x0), w))
325-
y0 = max(0, min(int(y0), h))
326-
x1 = max(x0, min(int(x1), w))
327-
y1 = max(y0, min(int(y1), h))
328-
return frame[y0:y1, x0:x1] if (x1 > x0 and y1 > y0) else frame
329-
330316
def open(self) -> None:
331317
if pylon is None:
332318
raise RuntimeError("pypylon is required for the Basler backend but is not installed")
@@ -472,22 +458,6 @@ def read(self) -> tuple[np.ndarray, float]:
472458
self._actual_width = int(w)
473459
self._actual_height = int(h)
474460

475-
# --- Optional transforms ---
476-
if self._apply_transforms:
477-
# Rotation from CameraSettings
478-
rotation = int(getattr(self.settings, "rotation", 0) or 0)
479-
if rotation:
480-
frame = self._rotate(frame, rotation)
481-
482-
# Crop from CameraSettings
483-
x0 = int(getattr(self.settings, "crop_x0", 0) or 0)
484-
y0 = int(getattr(self.settings, "crop_y0", 0) or 0)
485-
x1 = int(getattr(self.settings, "crop_x1", 0) or 0)
486-
y1 = int(getattr(self.settings, "crop_y1", 0) or 0)
487-
488-
if x0 or y0 or x1 or y1:
489-
frame = self._apply_crop(frame, x0, y0, x1, y1)
490-
491461
return frame, time.time()
492462

493463
def close(self) -> None:

0 commit comments

Comments
 (0)