From b21a88b5cf7267c41097f53f959ea4b41a46cd65 Mon Sep 17 00:00:00 2001 From: Tyler Benster Date: Tue, 21 Jul 2020 18:03:19 -0700 Subject: [PATCH] update for Vimba 4 / pymba v0.3.7 --- stytra/hardware/video/cameras/avt.py | 36 +++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/stytra/hardware/video/cameras/avt.py b/stytra/hardware/video/cameras/avt.py index bd5dbc8f..94b93553 100644 --- a/stytra/hardware/video/cameras/avt.py +++ b/stytra/hardware/video/cameras/avt.py @@ -3,7 +3,7 @@ try: from pymba import Vimba - from pymba.vimbaexception import VimbaException + from pymba.vimba_exception import VimbaException except ImportError: pass @@ -41,7 +41,7 @@ def open_camera(self): messages = [] # If there are multiple cameras, only the first one is used (this may # change): - camera_ids = self.vimba.getCameraIds() + camera_ids = self.vimba.camera_ids() if len(camera_ids) > 1: messages.append( "I:Multiple cameras detected: {}. {} wiil be used.".format( @@ -50,16 +50,16 @@ def open_camera(self): ) else: messages.append("I:Detected camera {}.".format(camera_ids[0])) - self.cam = self.vimba.getCamera(camera_ids[0]) + self.cam = self.vimba.camera(0) # Start camera: - self.cam.openCamera() - self.frame = self.cam.getFrame() - self.frame.announceFrame() + self.cam.open() + self.frame = self.cam.new_frame() + self.frame.announce() - self.cam.startCapture() - self.frame.queueFrameCapture() - self.cam.runFeatureCommand("AcquisitionStart") + self.cam.start_capture() + self.frame.queue_for_capture() + self.cam.run_feature_command("AcquisitionStart") return messages @@ -94,15 +94,13 @@ def set(self, param, val): def read(self): """ """ try: - self.frame.waitFrameCapture(self.timeout_ms) - self.frame.queueFrameCapture() - - raw_data = self.frame.getBufferByteData() - + self.frame.wait_for_capture(self.timeout_ms) + self.frame.queue_for_capture() + raw_data = self.frame.buffer_data() frame = np.ndarray( buffer=raw_data, dtype=np.uint8, - shape=(self.frame.height, self.frame.width), + shape=(self.frame.data.height, self.frame.data.width), ) except VimbaException: @@ -112,8 +110,8 @@ def read(self): def release(self): """ """ - self.frame.waitFrameCapture(self.timeout_ms) - self.cam.runFeatureCommand("AcquisitionStop") - self.cam.endCapture() - self.cam.revokeAllFrames() + self.frame.wait_for_capture(self.timeout_ms) + self.cam.run_feature_command("AcquisitionStop") + self.cam.end_capture() + self.cam.revoke_all_frames() self.vimba.shutdown()