From 3431a2602f6520ceef1045036f427bddc840c8ec Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Wed, 1 Jul 2020 14:18:27 +0200 Subject: [PATCH] added methods to get the image, width and height --- cameras/cameraclient.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cameras/cameraclient.py b/cameras/cameraclient.py index 809bfaf..6f52148 100644 --- a/cameras/cameraclient.py +++ b/cameras/cameraclient.py @@ -77,6 +77,29 @@ class CameraClient: def clear_buffer(self): caput(self.name + ":CLEARMEM", 1) # Clear Buffer + def width(self): + res = caget(self.name + ":WIDTH") + if res is None: + raise RuntimeError("Could not caget width") + return int(res) + + def height(self): + res = caget(self.name + ":HEIGHT") + if res is None: + raise RuntimeError("Could not caget height") + return int(res) + + def get(self): + waveform = caget(self.name + ":FPICTURE") + if waveform is None: + raise RuntimeError("Could not caget waveform") + width = self.width() + height = self.height() + length = width * height + waveform = waveform[:length] + image = waveform.reshape(height, width) + return image + def get_max_roi(self): current_roi = self.get_roi() self.reset_roi()