diff options
| author | morefigs <morefigs@gmail.com> | 2019-02-11 17:07:41 +1100 |
|---|---|---|
| committer | morefigs <morefigs@gmail.com> | 2019-02-11 17:07:41 +1100 |
| commit | a3ad21c6b05754315825f8ae62def71a0c73988a (patch) | |
| tree | b3f0c6f61f28b32c553f95bcf5238d0a4e0658ef /examples/camera/opencv_capture_image_with_callback.py | |
| parent | 367295804b27d3eeef27bb85826426828a6bda03 (diff) | |
| download | pymba-a3ad21c6b05754315825f8ae62def71a0c73988a.tar.gz pymba-a3ad21c6b05754315825f8ae62def71a0c73988a.zip | |
added convenience functions for acquiring single images and streaming images indefinitely, with examples.
Diffstat (limited to 'examples/camera/opencv_capture_image_with_callback.py')
| -rw-r--r-- | examples/camera/opencv_capture_image_with_callback.py | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/examples/camera/opencv_capture_image_with_callback.py b/examples/camera/opencv_capture_image_with_callback.py deleted file mode 100644 index 67cabdf..0000000 --- a/examples/camera/opencv_capture_image_with_callback.py +++ /dev/null @@ -1,44 +0,0 @@ -from time import sleep -import cv2 -from pymba import Vimba -from pymba.frame import Frame - - -def on_callback(completed_frame: Frame): - print('Callback called!') - - # get the image data as a numpy array - image = completed_frame.buffer_data_numpy() - - # display image - cv2.imshow(camera.camera_id, image) - # waits for user to close image - cv2.waitKey(0) - - -if __name__ == '__main__': - - with Vimba() as vimba: - camera = vimba.camera(0) - camera.open() - - # setup camera and frame and capture a single image - camera.AcquisitionMode = 'SingleFrame' - frame = camera.new_frame() - frame.announce() - camera.start_capture() - frame.queue_for_capture(on_callback) - camera.run_feature_command('AcquisitionStart') - camera.run_feature_command('AcquisitionStop') - - # wait long enough for the frame callback to be called - for _ in range(100): - sleep(0.1) - print('.', end='') - - # stop capturing and clean up - camera.end_capture() - camera.flush_capture_queue() - camera.revoke_all_frames() - - camera.close() |
