Skip to content

Commit

Permalink
Merge pull request #42 from tbenst/pymba_update
Browse files Browse the repository at this point in the history
update for Vimba 4 / pymba v0.3.7
  • Loading branch information
vigji committed Mar 8, 2021
2 parents 06d22a3 + b21a88b commit 3368c0d
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions stytra/hardware/video/cameras/avt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

try:
from pymba import Vimba
from pymba.vimbaexception import VimbaException
from pymba.vimba_exception import VimbaException
except ImportError:
pass

Expand Down Expand Up @@ -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(
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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()

0 comments on commit 3368c0d

Please sign in to comment.