diff options
| author | morefigs <morefigs@gmail.com> | 2016-05-16 11:50:03 +1000 |
|---|---|---|
| committer | morefigs <morefigs@gmail.com> | 2016-05-16 11:50:03 +1000 |
| commit | 9cbcd5c1700907a90ef7e0d7ad019da25943bc2c (patch) | |
| tree | 07f1b394eb8e441c7a76542553a2a6be7bb5947d | |
| parent | 9d7f4f3beaa9c6da59f41f4561f4284414a1894b (diff) | |
| parent | 374d41b3958438eb1610d6998f02c833a60c8f46 (diff) | |
| download | pymba-9cbcd5c1700907a90ef7e0d7ad019da25943bc2c.tar.gz pymba-9cbcd5c1700907a90ef7e0d7ad019da25943bc2c.zip | |
Merge pull request #37 from jrast/feature/FrameToNumpy
Direct conversion from frame data to numpy array
| -rw-r--r-- | pymba/vimbaframe.py | 11 |
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)) + |
