Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def grab_image():
try:
camera = pylon.InstantCamera(
pylon.TlFactory.GetInstance().CreateFirstDevice())
camera.Open()
result = camera.GrabOne(100)
camera.Close()
return result
except genicam.GenericException as e:
print("Could not grab an image: ", e.GetDescription())
def __init__(self, cam_idx=0, **kwargs):
super().__init__(**kwargs)
self.camera = pylon.InstantCamera(
pylon.TlFactory.GetInstance().CreateFirstDevice()
)
def __init__(self, identifier, *args, **kw):
# available_cameras = pypylon.factory.find_devices()
factory = pylon.TlFactory.GetInstance()
available_cameras = factory.EnumerateDevices()
self.debug('Available cameras {}'.format(available_cameras))
try:
try:
dev = available_cameras[int(identifier)]
except ValueError:
dev = next((c for c in available_cameras if c.user_defined_name == identifier), None)
cam = pylon.InstantCamera(factory.CreateDevice(dev))
# cam = pypylon.factory.create_device(dev)
except (IndexError, NameError):
cam = None
self._cam = cam
self.pixel_depth = 255
self._grabber = None
self._setting_config = False
super(BaslerPylonCamera, self).__init__(*args, **kw)