From 374d41b3958438eb1610d6998f02c833a60c8f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Rast?= Date: Thu, 12 May 2016 16:06:16 +0200 Subject: Direct conversion from framedata to numpy array --- pymba/vimbaframe.py | 11 +++++++++-- 1 file 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)) + -- cgit v1.2.3