Installing pymba on Windows

This is a quick post describing how to install the pymba package on Windows. Basically, you have to install the AVT Vimba package (v. 1.3+), Python 2.7.x and the pymba package.

Installing the packages

First, download and install the Vimba SDK from the Allied Vision Tech website. Be sure that you install the Vimba IEEE Firewire drivers  These are needed to talk to the Vimba API and thus, the camera.

Then, download the most recent pymba package from morefigs pymba repository. Either you clone it your local git repository or you download the zip file. Doing the latter, extract the pymba-master folder to any place, then open a command prompt (typing CMD when the start menu is opened and then press ENTER).

Navigate to the pymba-master folder. Install the package using the following line:

python install

Then, type python and press Enter to open a python shell. With the command import pymba you should be able to import the pymba library without any errors. If so, the path to Vimba is probably wrong and has to be adjusted. The best way is to edit the file and adjust the paths. This is for example necessary if you have a more recent Vimba installation.

That’s it. Now it should work.


I am adopting the example code from the pymba git repository and add some fancy stuff:
Briefly, I am using the pymba package to access the camera, the time library for calculating the framerate and OpenCV for showing the camera frame (and the frames per second [fps] burned on the image).

from pymba import *
import time, cv2

framei = 0
now = time.time()

# start Vimba
with Vimba() as vimba:
    # get system object
    system = vimba.getSystem()

    # list available cameras (after enabling discovery for GigE cameras)
    if system.GeVTLIsPresent:
    cameraIds = vimba.getCameraIds()
    for cameraId in cameraIds:
        print 'Camera ID:', cameraId

    # get and open a camera
    camera0 = vimba.getCamera(cameraIds[0])

    # list camera features
    cameraFeatureNames = camera0.getFeatureNames()
    for name in cameraFeatureNames:
        print 'Camera feature:', name

    # get the value of a feature
    print camera0.AcquisitionMode

    # set the value of a feature
    camera0.AcquisitionMode = 'SingleFrame'

    # create new frames for the camera
    frame0 = camera0.getFrame()    # creates a frame
    frame1 = camera0.getFrame()    # creates a second frame

    # announce frame

    # capture a camera image

    while 1:
        # The 1000 may be adjusted to your needs
        # Common source for errors

        # get image data...
        imgData = frame0.getBufferByteData()

        moreUsefulImgData = np.ndarray(buffer = imgData,
                                       dtype = np.uint8,
                                       shape = (frame0.height,
        framei += 1
        # Only show every nth frame
        if framei % 7 == 0:
            cv2.putText(moreUsefulImgData,"%d fps" % (framei/(time.time()-now)), (10,10), cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.5, (255,255,255))   
            key = cv2.waitKey(1)
        if key == ord("q"):
    # clean up after capture
print framei,"-", time.time()-now,"s - ", framei/(time.time()-now)