aboutsummaryrefslogtreecommitdiff
path: root/examples/camera/opencv_acquire_image.py
blob: 3fd8e03e46040cefead7a22203944aa5b9eb92b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from pymba import Vimba, VimbaException
from examples.camera.display_frame import display_frame


if __name__ == '__main__':

    with Vimba() as vimba:
        camera = vimba.camera(0)
        camera.open()

        camera.arm('SingleFrame')

        # capture a single frame, more than once if desired
        for i in range(1):
            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()

        camera.close()