Created
December 21, 2017 07:34
-
-
Save npyoung/80c728569b2a3ad575395354c16bfaea to your computer and use it in GitHub Desktop.
Testing FlyCapture (Point Grey camera)
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 numpy as np | |
| import PyCapture2 | |
| from sys import exit | |
| if __name__ == '__main__': | |
| # Ensure sufficient cameras are found | |
| bus = PyCapture2.BusManager() | |
| camInfos = bus.discoverGigECameras() | |
| if not len(camInfos): | |
| print("No suitable GigE cameras found. Exiting...") | |
| exit() | |
| cam = PyCapture2.GigECamera() | |
| uID = bus.getCameraFromIndex(0) | |
| ifaceType = bus.getInterfaceTypeFromGuid(uID) | |
| if ifaceType != PyCapture2.INTERFACE_TYPE.GIGE: | |
| print("Interface is not GigE. Exiting...") | |
| print("Connecting to Camera...") | |
| cam.connect(uID) | |
| print("Querying GigE image setting information...") | |
| imgSetInfo = cam.getGigEImageSettingsInfo() | |
| imgSet = PyCapture2.GigEImageSettings() | |
| imgSet.offsetX = 0 | |
| imgSet.offsetY = 0 | |
| imgSet.height = imgSetInfo.maxHeight | |
| imgSet.width = imgSetInfo.maxWidth | |
| imgSet.pixelFormat = PyCapture2.PIXEL_FORMAT.MONO8 | |
| print("Setting GigE image settings...") | |
| cam.setGigEImageSettings(imgSet) | |
| print("Starting image capture...") | |
| cam.startCapture() | |
| import time | |
| t0 = time.time() | |
| for i in range(1000): | |
| try: | |
| image = cam.retrieveBuffer() | |
| except PyCapture2.Fc2error as fc2Err: | |
| print("Error retrieving buffer : ", fc2Err) | |
| img_data = image.getData() | |
| print(i / (time.time() - t0)) | |
| cam.stopCapture() | |
| cam.disconnect() | |
| input("Done! Press Enter to exit...\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment