diff options
| -rw-r--r-- | pymba/vimbaframe.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/pymba/vimbaframe.py b/pymba/vimbaframe.py index b6bc139..98275cd 100644 --- a/pymba/vimbaframe.py +++ b/pymba/vimbaframe.py @@ -82,16 +82,37 @@ class VimbaFrame(object): if errorCode != 0: raise VimbaException(errorCode) - def queueFrameCapture(self): + 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(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), - None) # callback not implemented + self._frameCallbackWrapper_C) if errorCode != 0: raise VimbaException(errorCode) |
