From 9066b9458872b44be8df4563a13858e10d712f05 Mon Sep 17 00:00:00 2001 From: morefigs Date: Sat, 13 Apr 2019 15:54:36 +1000 Subject: Catch timeout in single frame acquisition example --- .gitignore | 2 ++ examples/camera/opencv_acquire_image.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 55ff08c..7b3ad35 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ nosetests.xml venv* scrap/ + +notes.txt \ No newline at end of file diff --git a/examples/camera/opencv_acquire_image.py b/examples/camera/opencv_acquire_image.py index 741f449..3fd8e03 100644 --- a/examples/camera/opencv_acquire_image.py +++ b/examples/camera/opencv_acquire_image.py @@ -1,4 +1,4 @@ -from pymba import Vimba +from pymba import Vimba, VimbaException from examples.camera.display_frame import display_frame @@ -12,8 +12,17 @@ if __name__ == '__main__': # capture a single frame, more than once if desired for i in range(1): - frame = camera.acquire_frame() - display_frame(frame, 0) + try: + frame = camera.acquire_frame() + display_frame(frame, 0) + except VimbaException as e: + # rearm camera upon frame timeout + if e.error_code == VimbaException.ERR_TIMEOUT: + print(e) + camera.disarm() + camera.arm('SingleFrame') + else: + raise camera.disarm() -- cgit v1.2.3