diff options
| author | morefigs <morefigs@gmail.com> | 2016-05-16 12:36:46 +1000 |
|---|---|---|
| committer | morefigs <morefigs@gmail.com> | 2016-05-16 12:36:46 +1000 |
| commit | 232256920ea12feb758f643c65d75747f97ed5ce (patch) | |
| tree | 77f829206922761d1ee54fac3d14b0e91eb51d40 | |
| parent | 02efe9142ebeb5cb693e23da10ea517994b7191e (diff) | |
| parent | 807042c66f31659131095a4192905320b77bfd8f (diff) | |
| download | pymba-232256920ea12feb758f643c65d75747f97ed5ce.tar.gz pymba-232256920ea12feb758f643c65d75747f97ed5ce.zip | |
Merge pull request #35 from jrast/bugfix/cameraInfoCache
Don't cache cameraInfos
| -rw-r--r-- | pymba/vimba.py | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/pymba/vimba.py b/pymba/vimba.py index 97eb96e..1096917 100644 --- a/pymba/vimba.py +++ b/pymba/vimba.py @@ -24,7 +24,6 @@ class Vimba(object): # lists of VimbaCameraInfo and VimbaInterfaceInfo objects # can't be called before startup() so populate later - self._cameraInfos = None self._interfaceInfos = None # dict of {camera ID : VimbaCamera object} as we don't want to forget @@ -38,7 +37,7 @@ class Vimba(object): def __enter__(self): """ Define vimba context for safe execution. - + The vimba object should be used like this: # start Vimba with Vimba() as vimba: @@ -100,36 +99,33 @@ class Vimba(object): :returns: list -- camera info for available cameras. """ - if self._cameraInfos is None: - # args - dummyCameraInfo = structs.VimbaCameraInfo() - numFound = c_uint32(-1) + # args + dummyCameraInfo = structs.VimbaCameraInfo() + numFound = c_uint32(-1) - # call once just to get the number of cameras - # Vimba DLL will return an error code - errorCode = VimbaDLL.camerasList(byref(dummyCameraInfo), - 0, - byref(numFound), - sizeof(dummyCameraInfo)) - if errorCode != 0 and errorCode != -9: - print errorCode - raise VimbaException(errorCode) + # call once just to get the number of cameras + # Vimba DLL will return an error code + errorCode = VimbaDLL.camerasList(byref(dummyCameraInfo), + 0, + byref(numFound), + sizeof(dummyCameraInfo)) + if errorCode != 0 and errorCode != -9: + raise VimbaException(errorCode) - numCameras = numFound.value + numCameras = numFound.value - # args - cameraInfoArray = (structs.VimbaCameraInfo * numCameras)() + # args + cameraInfoArray = (structs.VimbaCameraInfo * numCameras)() - # call again to get the features - # Vimba DLL will return an error code - errorCode = VimbaDLL.camerasList(cameraInfoArray, - numCameras, - byref(numFound), - sizeof(dummyCameraInfo)) - if errorCode != 0: - raise VimbaException(errorCode) - self._cameraInfos = list(camInfo for camInfo in cameraInfoArray) - return self._cameraInfos + # call again to get the features + # Vimba DLL will return an error code + errorCode = VimbaDLL.camerasList(cameraInfoArray, + numCameras, + byref(numFound), + sizeof(dummyCameraInfo)) + if errorCode != 0: + raise VimbaException(errorCode) + return list(camInfo for camInfo in cameraInfoArray) def getSystem(self): """ |
