aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Rast <juergr@gmail.com>2016-05-12 16:06:16 +0200
committerJürg Rast <juergr@gmail.com>2016-05-12 16:06:16 +0200
commit374d41b3958438eb1610d6998f02c833a60c8f46 (patch)
tree07f1b394eb8e441c7a76542553a2a6be7bb5947d
parent9d7f4f3beaa9c6da59f41f4561f4284414a1894b (diff)
downloadpymba-374d41b3958438eb1610d6998f02c833a60c8f46.tar.gz
pymba-374d41b3958438eb1610d6998f02c833a60c8f46.zip
Direct conversion from framedata to numpy array
-rw-r--r--pymba/vimbaframe.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/pymba/vimbaframe.py b/pymba/vimbaframe.py
index ececc71..5735430 100644
--- a/pymba/vimbaframe.py
+++ b/pymba/vimbaframe.py
@@ -4,6 +4,7 @@ from vimbaexception import VimbaException
from vimbadll import VimbaDLL
from vimbadll import VimbaC_MemoryBlock
from ctypes import *
+import numpy as np
"""
Map pixel formats to bytes per pixel.
@@ -90,11 +91,11 @@ class VimbaFrame(object):
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
@@ -157,3 +158,9 @@ class VimbaFrame(object):
data.contents))
return array
+
+ def getImage(self):
+ cframe = self._frame
+ data = cast(cframe.buffer, POINTER(c_ubyte * cframe.imageSize))
+ return np.ndarray(buffer=data.contents, dtype=np.uint8, shape=(cframe.height, cframe.width))
+