diff options
| author | morefigs <morefigs@gmail.com> | 2017-08-26 12:42:23 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-26 12:42:23 +1000 |
| commit | 2baf48689a630d30831d8ac3f48db90082eabb12 (patch) | |
| tree | e2f71105c77eae9ba395d6ed3aebbfdce52645c0 | |
| parent | 3396cbf5a809635cbe56910cb5cf024b3493301d (diff) | |
| parent | e2fd8760222eaa31fd50b3f3547ef6012943944f (diff) | |
| download | pymba-2baf48689a630d30831d8ac3f48db90082eabb12.tar.gz pymba-2baf48689a630d30831d8ac3f48db90082eabb12.zip | |
Merge pull request #55 from seahawk67/master
getCameraInfo and getCamera extended
| -rw-r--r-- | pymba/vimba.py | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/pymba/vimba.py b/pymba/vimba.py index 705838a..a1ffeaa 100644 --- a/pymba/vimba.py +++ b/pymba/vimba.py @@ -171,14 +171,19 @@ class Vimba(object): Gets camera info object of specified camera. :param cameraId: the ID of the camera object to get. + This might not only be a cameraId as returned by getCameraIds() + but also e.g. a serial number. Check the Vimba documentation for + other possible values. :returns: VimbaCameraInfo object -- the camera info object specified. """ - # don't do this live as we already have this info - # return info object if it exists - for camInfo in self._getCameraInfos(): - if camInfo.cameraIdString == cameraId: - return camInfo + cameraInfo = structs.VimbaCameraInfo() + errorCode = VimbaDLL.cameraInfoQuery(cameraId.encode(), + cameraInfo, + sizeof(cameraInfo)) + if errorCode == 0: + return cameraInfo + # otherwise raise error raise VimbaException(-50) @@ -204,7 +209,10 @@ class Vimba(object): Gets camera object based on camera ID string. Will not recreate camera object if it already exists. - :param cameraId: the ID of the camera. + :param cameraId: the ID of the camera object to get. + This might not only be a cameraId as returned by getCameraIds() + but also e.g. a serial number. Check the Vimba documentation for + other possible values. :returns: VimbaCamera object -- the camera object specified. """ @@ -214,7 +222,20 @@ class Vimba(object): if cameraId not in self._cameras: self._cameras[cameraId] = VimbaCamera(cameraId) return self._cameras[cameraId] - raise VimbaException(-50) + else: + # the given string might not be a camera ID -> check for other IDs + cameraInfo = structs.VimbaCameraInfo() + errorCode = VimbaDLL.cameraInfoQuery(cameraId.encode(), + cameraInfo, + sizeof(cameraInfo)) + if errorCode != 0: + raise VimbaException(-50) # camera not found + + cameraIdString = cameraInfo.cameraIdString.decode() + if cameraIdString not in self._cameras: + self._cameras[cameraIdString] = VimbaCamera(cameraIdString) + return self._cameras[cameraIdString] + def getVersion(self): """ |
