def startup(self):
        """Handle the startup of the camera.

        Raises
        ------
        CameraNotFound
            Raises this exception if there is an issue with the camera.
        """
        self.goodFrames = 0
        self.badFrames = 0
        self.totalFrames = 0
        self.vimba = pv.Vimba()
        self.vimba.startup()
        time.sleep(0.2)
        cameraIds = self.vimba.camera_ids()
        try:
            self.cameraPtr = self.vimba.camera(cameraIds[self.cameraIndex])
        except IndexError:
            raise CameraNotFound('Camera not found ... check power or connection!')

        self.cameraPtr.open()
        #self.cameraPtr.GevSCPSPacketSize = 1500
        try:
            currentSbps = self.cameraPtr.StreamBytesPerSecond
            self.cameraPtr.StreamBytesPerSecond = self.STREAM_BYTES_PER_SECOND
        except pv.VimbaException:
            message = f'Issue with ethernet cable ... StreamBytesPerSecond: {currentSbps}'
            message += f' instead of {self.STREAM_BYTES_PER_SECOND}'
            raise CameraNotFound(message)
        self.height = self.cameraPtr.HeightMax
        self.width = self.cameraPtr.WidthMax
        self.frameShape = (self.height, self.width)
        self.cameraPtr.Height = self.height
        self.cameraPtr.Width = self.width
        self.cameraPtr.OffsetX = 0
        self.cameraPtr.OffsetY = 0
        self.cameraPtr.GainAuto = 'Off'
        self.cameraPtr.GainRaw = 0
        self.cameraPtr.ExposureAuto = 'Off'
        self.cameraPtr.TriggerSource = 'Freerun'
        self.cameraPtr.PixelFormat = 'Mono12'
        self.cameraPtr.ExposureTimeAbs = self.roiExposureTime

        self.cameraPtr.arm('Continuous', self.convertFrame)
Beispiel #2
0
This demonstration assumes you have already installed Pymba and followed the installation instructions there:
https://github.com/morefigs/pymba

MoviePy is used to save the frames to a video file for later viewing, while the frame's mean intensity is
printed in real time. MoviePy can be installed from pip nicely.
"""
import pymba
from moviepy.video.io.ffmpeg_writer import FFMPEG_VideoWriter as VidWriter
from skimage.color import gray2rgb
import time

# Start by getting the Vimba API set up
# Using the context (i.e. 'with' syntax) is a good idea
# If something crashes, vimba.shutdown() will get called automatically
# and your camera will not get left in an unusable state!
with pymba.Vimba() as vimba:
    print vimba.getVersion()

    # Find any cameras that are attached
    system = pymba.getSystem()
    system.runFeatureCommand("GeVDiscoveryAllOnce")
    time.sleep(
        0.2
    )  # feature commands run in another thread, but need a moment to execute
    camera_ids = vimba.getCameraIds()

    # Just use the first camera we found
    vmb_cam = vimba.getCamera(camera_ids[0])
    vmb_cam.openCamera()

    # Set up the camera with the right parameters