コード例 #1
0
    def _getInterfaceInfos(self):
        """
        Gets interface info of all available interfaces.

        :returns: list -- interface info for available interfaces.
        """
        if self._interfaceInfos is None:
            # args
            dummyInterfaceInfo = structs.VimbaInterfaceInfo()
            numFound = c_uint32(-1)

            # call once just to get the number of interfaces
            # Vimba DLL will return an error code
            errorCode = VimbaDLL.interfacesList(byref(dummyInterfaceInfo), 0,
                                                byref(numFound),
                                                sizeof(dummyInterfaceInfo))
            if errorCode != 0:
                print errorCode
                raise VimbaException(errorCode)

            numInterfaces = numFound.value

            # args
            interfaceInfoArray = (structs.VimbaInterfaceInfo * numInterfaces)()

            # call again to get the features
            # Vimba DLL will return an error code
            errorCode = VimbaDLL.interfacesList(interfaceInfoArray,
                                                numInterfaces, byref(numFound),
                                                sizeof(dummyInterfaceInfo))
            if errorCode != 0:
                raise VimbaException(errorCode)
            self._interfaceInfos = list(
                interfaceInfo for interfaceInfo in interfaceInfoArray)
        return self._interfaceInfos
コード例 #2
0
    def _getCameraInfos(self):
        """
        Gets camera info of all attached cameras.

        :returns: list -- camera info for available cameras.
        """
        if self._cameraInfos is None:
            # 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)

            numCameras = numFound.value

            # 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
コード例 #3
0
ファイル: vimbaobject.py プロジェクト: VaporC/vimba-mjpeg
    def readRegister(self, address):
        # note that the underlying Vimba function allows reading of an array
        # of registers, but only one address/value at a time is implemented
        # here
        """
        Read from a register of the module (camera).

        :param address: the address of the register to read.

        :returns: int -- value of register.
        """
        readCount = 1

        # check address validity
        try:
            regAddress = c_uint64(int(address, 16))
        except:
            raise VimbaException(-52)

        regData = c_uint64()
        numCompleteReads = c_uint32()

        errorCode = VimbaDLL.registersRead(self.handle,
                                           readCount,
                                           byref(regAddress),
                                           byref(regData),
                                           byref(numCompleteReads))

        if errorCode != 0:
            raise VimbaException(errorCode)

        return regData.value
コード例 #4
0
ファイル: vimbaobject.py プロジェクト: VaporC/vimba-mjpeg
    def writeRegister(self, address, value):
        # note that the underlying Vimba function allows writing of an array
        # of registers, but only one address/value at a time is implemented
        # here
        """
        Read from a register of the module (camera).

        :param address: the address of the register to read.
        :param value: the value to set in hex.
        """
        writeCount = 1

        # check address validity
        try:
            regAddress = c_uint64(int(address, 16))
        except:
            raise VimbaException(-52)

        # check value validity
        try:
            regData = c_uint64(int(value, 16))
        except:
            raise VimbaException(-52)

        numCompleteWrites = c_uint32()

        errorCode = VimbaDLL.registersWrite(self.handle,
                                            writeCount,
                                            byref(regAddress),
                                            byref(regData),
                                            byref(numCompleteWrites))
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #5
0
    def revokeFrame(self):
        """
		Revoke a frame from the API.
		"""
        errorCode = VimbaDLL.frameRevoke(self._handle, byref(self._frame))
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #6
0
ファイル: vimbaframe.py プロジェクト: jsalort/pymba
    def announceFrame(self):
        """
        Announce frames to the API that may be queued for frame capturing later.

        Runs VmbFrameAnnounce

        Should be called after the frame is created.  Call startCapture
        after this method.
        """
        # size of expected frame
        sizeOfFrame = self.payloadSize

        # keep this reference to keep block alive for life of frame
        self._cMem = VimbaC_MemoryBlock(sizeOfFrame)
        # set buffer to have length of expected payload size
        self._frame.buffer = self._cMem.block

        # set buffer size to expected payload size
        self._frame.bufferSize = sizeOfFrame

        errorCode = VimbaDLL.frameAnnounce(self._handle, byref(self._frame),
                                           sizeof(self._frame))

        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #7
0
ファイル: vimbaframe.py プロジェクト: jsalort/pymba
    def queueFrameCapture(self, frameCallback=None):
        """
        Queue frames that may be filled during frame capturing.
        Runs VmbCaptureFrameQueue

        Call after announceFrame and startCapture

        Callback must accept argument of type frame. Remember to requeue the
        frame by calling frame.queueFrameCapture(frameCallback) at the end of
        your callback function.
        """
        # remember the given callback function
        self._frameCallback = frameCallback

        # define a callback wrapper here so it doesn't bind self
        def frameCallbackWrapper(cam_handle, p_frame):
            # call the user's callback with the self bound outside the wrapper
            # ignore the frame pointer since we already know the callback
            # refers to this frame
            self._frameCallback(self)

        if self._frameCallback is None:
            self._frameCallbackWrapper_C = None
        else:
            # keep a reference to prevent gc issues
            self._frameCallbackWrapper_C = VimbaDLL.frameDoneCallback(
                frameCallbackWrapper)

        errorCode = VimbaDLL.captureFrameQueue(self._handle,
                                               byref(self._frame),
                                               self._frameCallbackWrapper_C)
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #8
0
ファイル: vimbainterface.py プロジェクト: arasharchor/pymba
    def closeInterface(self):
        """
		Close the interface.
		"""
        errorCode = VimbaDLL.interfaceClose(self._handle)
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #9
0
 def closeCamera(self):
     """
     Close the camera.
     """
     errorCode = VimbaDLL.cameraClose(self._handle)
     if errorCode != 0:
         raise VimbaException(errorCode)
コード例 #10
0
 def flushCaptureQueue(self):
     """
     Flush the capture queue.
     """
     errorCode = VimbaDLL.captureQueueFlush(self._handle)
     if errorCode != 0:
         raise VimbaException(errorCode)
コード例 #11
0
 def revokeAllFrames(self):
     """
     Revoke all frames assigned to the camera.
     """
     errorCode = VimbaDLL.frameRevokeAll(self._handle)
     if errorCode != 0:
         raise VimbaException(errorCode)
コード例 #12
0
 def startCapture(self):
     """
     Prepare the API for incoming frames.
     """
     errorCode = VimbaDLL.captureStart(self._handle)
     if errorCode != 0:
         raise VimbaException(errorCode)
コード例 #13
0
 def endCapture(self):
     """
     Stop the API from being able to receive frames.
     """
     errorCode = VimbaDLL.captureEnd(self._handle)
     if errorCode != 0:
         raise VimbaException(errorCode)
コード例 #14
0
    def waitFrameCapture(self, timeout=2000):
        """
		Wait for a queued frame to be filled (or dequeued).
		"""
        errorCode = VimbaDLL.captureFrameWait(self._handle, byref(self._frame),
                                              timeout)
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #15
0
 def startup(self):
     """
     Initialize the VimbaC API.
     """
     # Vimba DLL will return an error code
     errorCode = VimbaDLL.startup()
     if errorCode != 0:
         raise VimbaException(errorCode)
コード例 #16
0
ファイル: vimbainterface.py プロジェクト: arasharchor/pymba
    def openInterface(self):
        """
		Open the interface.
		"""
        errorCode = VimbaDLL.interfaceOpen(self._interfaceIdString,
                                           byref(self._handle))
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #17
0
    def queueFrameCapture(self):
        """
		Queue frames that may be filled during frame capturing.
		"""
        errorCode = VimbaDLL.captureFrameQueue(
            self._handle, byref(self._frame),
            None)  # callback not implemented, callback example in pico?
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #18
0
    def runFeatureCommand(self, featureName):
        """
		Run a feature command.
		
		:param featureName: the name of the feature.
		"""
        # run a command
        errorCode = VimbaDLL.featureCommandRun(self._handle, featureName)
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #19
0
ファイル: vimbaobject.py プロジェクト: VaporC/vimba-mjpeg
    def _getFeatureInfos(self):
        """
        Gets feature info of all available features. Will
        cause error if object/camera is not opened.

        :returns: list -- feature info for available features.
        """
        # check it's populated as can't populate it in __init__
        if self._featureInfos is None:
            # args
            dummyFeatureInfo = structs.VimbaFeatureInfo()
            numFound = c_uint32(-1)

            # call once to get number of available features
            # Vimba DLL will return an error code
            errorCode = VimbaDLL.featuresList(self._handle,
                                              byref(dummyFeatureInfo),
                                              0,
                                              byref(numFound),
                                              sizeof(dummyFeatureInfo))
            if errorCode != 0:
                raise VimbaException(errorCode)

            # number of features specified by Vimba
            numFeatures = numFound.value

            # args
            featureInfoArray = (structs.VimbaFeatureInfo * numFeatures)()

            # call again to get the features
            # Vimba DLL will return an error code
            errorCode = VimbaDLL.featuresList(self._handle,
                                              featureInfoArray,
                                              numFeatures,
                                              byref(numFound),
                                              sizeof(dummyFeatureInfo))
            if errorCode != 0:
                raise VimbaException(errorCode)

            self._featureInfos = list(
                featInfo for featInfo in featureInfoArray)
        return self._featureInfos
コード例 #20
0
ファイル: vimbadll.py プロジェクト: htsai-gb/pymba
    def __init__(self, blockSize):

        # assign memory block
        malloc = self._crtDLL.malloc
        malloc.argtypes = (c_size_t, )
        malloc.restype = c_void_p
        self._block = malloc(blockSize)  # todo check for NULL on failure

        # this seems to be None if too much memory is requested
        if self._block is None:
            raise VimbaException(-51)
コード例 #21
0
    def openCamera(self):
        """
        Open the camera.
        """
        # args for Vimba call
        cameraAccessMode = 1  # full access (see VmbAccessModeType)

        errorCode = VimbaDLL.cameraOpen(self._cameraIdString, cameraAccessMode,
                                        byref(self._handle))
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #22
0
ファイル: vimbafeature.py プロジェクト: VaporC/vimba-mjpeg
    def _setIntFeature(self, valueToSet):
        """
        Set the value of an integer feature.

        :param valueToSet: the int value to set for the feature.
        """

        errorCode = VimbaDLL.featureIntSet(self._handle,
                                           self._name,
                                           valueToSet)
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #23
0
ファイル: vimbafeature.py プロジェクト: VaporC/vimba-mjpeg
    def _setFloatFeature(self, valueToSet):
        """
        Set the value of a float feature.

        :param valueToSet: the float value to set for the feature.
        """

        errorCode = VimbaDLL.featureFloatSet(self._handle,
                                             self._name,
                                             valueToSet)
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #24
0
ファイル: vimbafeature.py プロジェクト: VaporC/vimba-mjpeg
    def _setEnumFeature(self, valueToSet):
        """
        Set the value of an enum feature.

        :param valueToSet: the enum value to set for the feature.
        """

        errorCode = VimbaDLL.featureEnumSet(self._handle,
                                            self._name,
                                            valueToSet)
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #25
0
ファイル: vimbafeature.py プロジェクト: VaporC/vimba-mjpeg
    def _setStringFeature(self, valueToSet):
        """
        Set the value of a string feature.

        :param valueToSet: the string value to set for the feature.
        """

        errorCode = VimbaDLL.featureStringSet(self._handle,
                                              self._name,
                                              valueToSet)
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #26
0
ファイル: vimbafeature.py プロジェクト: VaporC/vimba-mjpeg
    def _setBoolFeature(self, valueToSet):
        """
        Set the value of a bool feature.

        :param valueToSet: the bool value to set for the feature.
        """

        errorCode = VimbaDLL.featureBoolSet(self._handle,
                                            self._name,
                                            valueToSet)
        if errorCode != 0:
            raise VimbaException(errorCode)
コード例 #27
0
    def getCameraInfo(self, cameraId):
        """
        Gets camera info object of specified camera.

        :param cameraId: the ID of the camera object to get.

        :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
        # otherwise raise error
        raise VimbaException(-50)
コード例 #28
0
ファイル: vimbaobject.py プロジェクト: VaporC/vimba-mjpeg
    def getFeatureInfo(self, featureName):
        """
        Gets feature info object of specified feature.

        :param featureName: the name of the feature.

        :returns: VimbaFeatureInfo object -- the feature info object specified.
        """
        # don't do this live as we already have this info
        # return info object, if it exists
        for featInfo in self._getFeatureInfos():
            if featInfo.name == featureName:
                return featInfo
        # otherwise raise error
        raise VimbaException(-53)
コード例 #29
0
    def getInterfaceInfo(self, interfaceId):
        """
        Gets interface info object of specified interface.

        :param interfaceId: the ID of the interface object to get.

        :returns: VimbaInterfaceInfo object -- the interface info object specified.
        """
        # don't do this live as we already have this info
        # return info object if it exists
        for interfaceInfo in self._getInterfaceInfos():
            if interfaceInfo.interfaceIdString == interfaceId:
                return interfaceInfo
        # otherwise raise error
        raise VimbaException(-54)
コード例 #30
0
    def getCamera(self, cameraId):
        """
        Gets camera object based on camera ID string. Will not recreate
        camera object if it already exists.

        :param cameraId: the ID of the camera.

        :returns: VimbaCamera object -- the camera object specified.
        """
        # check ID is valid
        if cameraId in self.getCameraIds():
            # create it if it doesn't exist
            if cameraId not in self._cameras:
                self._cameras[cameraId] = VimbaCamera(cameraId)
            return self._cameras[cameraId]
        raise VimbaException(-50)