aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormorefigs <morefigs@gmail.com>2015-02-25 13:20:22 +1100
committermorefigs <morefigs@gmail.com>2015-02-25 13:20:22 +1100
commit02e566eb1dd7aa2d40350b6122f12f536c45a8c4 (patch)
tree3bc5670dcd7e0498c46810580a0b9b65c34d3a73
parent6497ba104b78686ee091ae4877255f7f78868645 (diff)
downloadpymba-02e566eb1dd7aa2d40350b6122f12f536c45a8c4.tar.gz
pymba-02e566eb1dd7aa2d40350b6122f12f536c45a8c4.zip
Added callback functionality to queueFrameCapture
-rw-r--r--pymba/vimbaframe.py27
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)