morefigs/pymba

Vimba other Error whilst capturing series of images

Closed this issue · 2 comments

Hi,

I am capturing Images with a Mako G-503C in Series using Pymba 0.1. After a (seemingly random) amount of Images I get the following error:

pymba.vimbaexception.VimbaException: Other error.

whilst calling announceFrame() method.
I use the following source Code:

import pymba
import numpy
import cv2
import time
Camera = None
Vimba = None
ID = "DEV_000F315C80FF"
def GetCamera():
    global ID
    global Camera
    global Vimba
    if Camera is None:
        # Create vimba instance
        Vimba = pymba.Vimba()
        # Startup vimba
        Vimba.startup()
        # Get system object
        System = Vimba.getSystem()
        # Discover cameras
        if System.GeVTLIsPresent:
            System.runFeatureCommand("GeVDiscoveryAllOnce")
            time.sleep(0.200)
        # Assign camera
        Camera = Vimba.getCamera(ID)
        # Open camera
        Camera.openCamera()
        # Set acquisition modes
        Camera.AcquisitionMode = "Continuous"
    return Camera
def Shutdown():
    global Vimba
    if Vimba is not None:
        Vimba.shutdown()
def Snapshot():
    Camera = GetCamera()
    # Start capture
    Camera.startCapture()
    # Assign frames
    Frames = [Camera.getFrame() for _ in range(1)]
    # Iterate each frame
    for Frame in Frames:
        # Announce frame
        Frame.announceFrame()
        # Queue frame capture
        Frame.queueFrameCapture()
    # Acquisition
    Camera.runFeatureCommand("AcquisitionStart")
    time.sleep(0.500)
    Camera.runFeatureCommand("AcquisitionStop")
    # Wait for frame buffer
    Frame.waitFrameCapture()
    # Convert image
    Image = numpy.ndarray(buffer=Frame.getBufferByteData(),
                          dtype=numpy.uint8,
                          shape=(Frame.height, Frame.width, 1)
                          )
    Image = cv2.cvtColor(Image, cv2.COLOR_BAYER_GR2RGB)
    Image = cv2.cvtColor(Image, cv2.COLOR_BGR2GRAY)
    # Save image
    cv2.imwrite("C:\\Temp\\test.jpg", Image)
    # Cleanup
    Camera.endCapture()
    Camera.revokeAllFrames()
counter = 0
while True:
    counter = counter + 1
    Snapshot()
    print(counter)

If i use my other camera Mako G-125B and my Mako G-125C then this happens never. So It might be as well a Hardware issue, but you never know...

You can't announce a frame after capture has started. I'm surprised it works for any cameras. Swapping start capture and announce frame functions should help.

I'd strongly recommended downloading Pymba 0.3.2 and trying the examples there, which are much simplified.

Thanks that solved the problem