Last active
June 15, 2016 07:05
-
-
Save jrast/e5965e27d1b201b4e33677077bb8827b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from pymba import Vimba | |
| print("Starting Vimba") | |
| vimba = Vimba() | |
| vimba.startup() | |
| print("Vimba Version: %s" % vimba.getVersion()) | |
| print("GigE Camera Discovery") | |
| system = vimba.getSystem() | |
| system.runFeatureCommand('GeVDiscoveryAllOnce') | |
| ids = vimba.getCameraIds() | |
| print("Available Cameras: %s" % ', '.join(ids)) | |
| cam = vimba.getCamera(ids[0]) | |
| cam.openCamera() | |
| cam.AcquisitionMode = 'Continuous' | |
| frames = [cam.getFrame() for _ in range(2)] | |
| map(lambda f: f.announceFrame(), frames) | |
| images = [] | |
| start = time.clock() | |
| def cb(frame): | |
| print("Entering Frame Callback. Time: %.2f" % (time.clock() - start)) | |
| print("Frame Information:") | |
| print(" pymba Frame: %s" % str(frame)) | |
| print(" vimba Frame: %s" % str(frame._frame)) | |
| print(" pymba Frame properties:") | |
| for p in ['width', 'height', 'payloadSize', 'pixel_bytes']: | |
| print(" frame.%s = %s" % (p, str(getattr(frame, p)))) | |
| print(" vimba Frame properties:") | |
| for p in ['ancillarySize', 'buffer', 'bufferSize', 'context', 'frameID', 'height', 'width', | |
| 'imageSize', 'offsetX', 'offsetY', 'pixelFormat', 'receiveFlags', 'receiveStatus', | |
| 'timestamp']: | |
| print(" frame._frame.%s = %s" % (p, str(getattr(frame._frame, p)))) | |
| images.append(frame.getImage().copy()) | |
| frame.queueFrameCapture(cb) | |
| cam.startCapture() | |
| map(lambda f: f.queueFrameCapture(cb), frames) | |
| print("Starting First Acquisition. Time: %.2f" % (time.clock() - start)) | |
| cam.runFeatureCommand('AcquisitionStart') | |
| print("Waiting 1 Seconds. Time: %.2f" % (time.clock() - start)) | |
| time.sleep(1) | |
| cam.runFeatureCommand('AcquisitionStop') | |
| print("Stopping Second Acquisition. Time: %.2f" % (time.clock() - start)) | |
| print("End Capture and Revoke all Frames") | |
| cam.endCapture() | |
| cam.flushCaptureQueue() | |
| cam.revokeAllFrames() | |
| cam.closeCamera() | |
| plt.show() | |
| print("Vimba Shutdown") | |
| vimba.shutdown() | |
| print("Captured %d Images" % len(images)) | |
| plt.figure("Caputred Images") | |
| plt.clf() | |
| plt.subplot(221) | |
| plt.imshow(images[0], cmap='gray') | |
| plt.title("Image Frame 1") | |
| plt.subplot(222) | |
| plt.imshow(images[1], cmap='gray') | |
| plt.title("Image Frame 2") | |
| plt.subplot(223) | |
| plt.imshow(images[0].astype(float) - images[1].astype(float)) | |
| plt.title("Difference Frame 1 - Frame 2") | |
| plt.colorbar() | |
| plt.subplot(224) | |
| plt.imshow(images[0].astype(float) - images[2].astype(float)) | |
| plt.title("Difference Frame 1 - Frame 3") | |
| plt.colorbar() | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment