blob: 5ca843445ad21fb2d13b14d09739607a500fb61c (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# pymba
pymba is a Python wrapper for the Allied Vision Technologies (AVT) Vimba C API. It wraps the VimbaC.dll file included in the AVT Vimba installation to provide a simple Python interface for AVT cameras. It currently supports most of the functionality provided by VimbaC.dll for 1394 cameras.
## Installation
Install the Vimba SDK from AVT to the default directory, and install at least:
- AVT 1394 Transport Layer
└ Core components
- AVT Vimba SDK
└ Core components
└ C API runtime components
└ Driver Installer
Run the AVTDriverInstaller tool and install the AVT Vimba SDK drivers.
Install pymba.
## Usage
### Testing installation
If Vimba and pymba are installed correctly, then the following code should give the installed Vimba version. No camera is needed.
from vimba import *
vimba = Vimba()
vimba.getVersion()
### Basic usage
The following code gives an example of basic usage. For clarity exceptions are not dealt with here.
from vimba import *
#### start Vimba
vimba = Vimba()
vimba.startup()
#### show Vimba version
print vimba.getVersion()
#### list available camera IDs
camIds = vimba.getCameraIds()
for cam in camIds:
print cam
#### create and open a camera
cam0 = vimba.getCamera(camIds[0])
cam0.openCamera()
#### list features of a camera
featNames = cam0.getFeatureNames()
for fn in featNames:
print fn
#### read info of a camera feature
featInfo = cam0.getFeatureInfo('AcquisitionMode')
for field in featInfo.getFieldNames():
print field, '--', getattr(featInfo, field)
#### get the value of a feature
print cam0.AcquisitionMode
#### set the value of a feature
cam0.AcquisitionMode = 'SingleFrame'
#### create new frames for the camera
frame0 = cam0.getFrame() # creates a frame
frame1 = cam0.getFrame() # creates a second frame
#### announce frame
frame0.announceFrame()
#### capture a camera image
cam0.startCapture()
frame0.queueFrameCapture()
cam0.runFeatureCommand('AcquisitionStart')
cam0.runFeatureCommand('AcquisitionStop')
frame0.waitFrameCapture()
#### get image data...
imgData = frame0.getBufferByteData()
#### ...or use NumPy for fast image display (for use with OpenCV, etc)
import numpy as np
moreUsefulImgData = np.ndarray(buffer = cam0.frame0.getBufferByteData(),
dtype = np.uint8,
shape = (cam0.frame0.height,
cam0.frame0.width,
1))
#### clean up after capture
cam0.endCapture()
cam0.revokeAllFrames()
#### close camera
cam0.closeCamera()
#### shutdown Vimba
vimba.shutdown()
### Handling Vimba exceptions
Handling exceptions can be done as shown below.
from vimba import *
try:
vimba = Vimba()
vimba.startup()
except VimbaException as e:
print e.message
## Known issues
* Not all API functions are wrapped (most are). For full list see vimbadll.py.
* Colour cameras have not been tested. B&W 1394 cameras have been tested under Windows with Vimba version 1.2.1.
* The VimbaC.dll file location has been hardcoded in vimbadll.py. It should be easy to change if needed.
|