Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, identifier, *args, **kw):
# Grep the first one and create a camera for it
try:
available_cameras = pypylon.factory.find_devices()
self.debug('Available cameras {}'.format(available_cameras))
cam = pypylon.factory.create_device(available_cameras[identifier])
except (IndexError, NameError):
cam = None
self._cam = cam
self.pixel_depth = 255
self._grabber = None
self._setting_config = False
super(PylonCamera, self).__init__(*args, **kw)
from __future__ import absolute_import, print_function, division
import pypylon
import matplotlib.pyplot as plt
import tqdm
import numpy as np
print('Build against pylon library version:', pypylon.pylon_version.version)
available_cameras = pypylon.factory.find_devices()
print('Available cameras are', available_cameras)
# Grep the first one and create a camera for it
cam = pypylon.factory.create_device(available_cameras[-1])
# We can still get information of the camera back
print('Camera info of camera object:', cam.device_info)
# Open camera and grep some images
cam.open()
# Hard code exposure time
# cam.properties['ExposureTime'] = 10000.0
cam.properties['PixelFormat'] = 'Mono12'
print(cam.properties['PixelSize'])
# Go to full available speed
# cam.properties['DeviceLinkThroughputLimitMode'] = 'Off'
for key in cam.properties.keys():
self.acquire_continuously = 0
self.acquisition_thread = None
self.feature_finder = _feature_finder
print "Finding valid cameras..."
time.sleep(1)
camera_list = pylon.factory.find_devices()
print camera_list
if(len(camera_list) <= 0):
raise Exception("Couldn't find a valid camera")
try:
print "Trying..."
self.camera = pylon.factory.create_device(camera_list[0])
self.camera.open()
print "Did it"
except:
print "No good"
raise Exception("Couldn't instantiate camera")
# self.camera.setAttribute("BinningX", 1)
# self.camera.setAttribute("BinningY", 1)
# try:
# self.timestampFrequency = self.camera.getUint32Attribute("TimeStampFrequency")
# print "Found TimestampFrequency of: %f" % self.timestampFrequency
# except:
# self.timestampFrequency = 1
# print "attribute: TimestampFrequency not found for camera, defaulting to 1"