From ba5683a10a8fca64ece8a4407d4b1a315afea2e6 Mon Sep 17 00:00:00 2001 From: Nathan van Beelen Date: Tue, 5 Mar 2024 15:43:52 +0100 Subject: [PATCH 1/2] Add interlacing support --- stytra/hardware/video/cameras/avt.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stytra/hardware/video/cameras/avt.py b/stytra/hardware/video/cameras/avt.py index bf4a7c8b..332ccf5a 100644 --- a/stytra/hardware/video/cameras/avt.py +++ b/stytra/hardware/video/cameras/avt.py @@ -22,10 +22,11 @@ class AvtCamera(Camera): """ - def __init__(self, camera_id=None, **kwargs): + def __init__(self, camera_id=None, interlacing=False, **kwargs): # Set timeout for frame acquisition. Give this as input? self.timeout_ms = 1000 self.camera_id = camera_id + self.interlacing = interlacing # some cameras look like they have a double image, these should be interlaced. super().__init__(**kwargs) @@ -111,6 +112,12 @@ def read(self): shape=(self.frame.data.height, self.frame.data.width), ) + if self.interlacing: + new_frame = np.empty(frame.shape, dtype=np.uint8) + new_frame[1::2] = frame[:246] + new_frame[::2] = frame[246:] + frame = new_frame + except VimbaException: frame = None From a37192009637d11af9f11f0d190792006439454a Mon Sep 17 00:00:00 2001 From: Nathan van Beelen Date: Tue, 5 Mar 2024 15:52:38 +0100 Subject: [PATCH 2/2] Reformat code with black --- stytra/hardware/video/cameras/avt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stytra/hardware/video/cameras/avt.py b/stytra/hardware/video/cameras/avt.py index 332ccf5a..f63f7d19 100644 --- a/stytra/hardware/video/cameras/avt.py +++ b/stytra/hardware/video/cameras/avt.py @@ -26,7 +26,7 @@ def __init__(self, camera_id=None, interlacing=False, **kwargs): # Set timeout for frame acquisition. Give this as input? self.timeout_ms = 1000 self.camera_id = camera_id - self.interlacing = interlacing # some cameras look like they have a double image, these should be interlaced. + self.interlacing = interlacing # some cameras look like they have a double image, these should be interlaced. super().__init__(**kwargs)