Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for Vimba 4 / pymba v0.3.7 #42

Merged
merged 1 commit into from
Mar 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()