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 setup.py 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 vimbadll.py 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: system.runFeatureCommand("GeVDiscoveryAllOnce") time.sleep(0.2) cameraIds = vimba.getCameraIds() for cameraId in cameraIds: print 'Camera ID:', cameraId # get and open a camera camera0 = vimba.getCamera(cameraIds) camera0.openCamera() # 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 frame0.announceFrame() # capture a camera image camera0.startCapture() frame0.queueFrameCapture() camera0.runFeatureCommand('AcquisitionStart') while 1: # The 1000 may be adjusted to your needs # Common source for errors frame0.waitFrameCapture(1000) frame0.queueFrameCapture() # get image data... imgData = frame0.getBufferByteData() moreUsefulImgData = np.ndarray(buffer = imgData, dtype = np.uint8, shape = (frame0.height, frame0.width, 1)) framei += 1 # Only show every nth frame # HIGHER FRAMERATE!! 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)) cv2.imshow("im",moreUsefulImgData) key = cv2.waitKey(1) if key == ord("q"): break # clean up after capture frame0.waitFrameCapture(1000) camera0.runFeatureCommand('AcquisitionStop') camera0.endCapture() camera0.revokeAllFrames() print framei,"-", time.time()-now,"s - ", framei/(time.time()-now) cv2.destroyAllWindows()