PCO Pixelfly Cameras

This module is for controlling PCO Pixelfly cameras.

Installation

This module requires the Pixelfly SDK and the cffi package.

You should install the Pixelfly SDK provided on PCO’s website. Specifically, this module requires pf_cam.dll to be available in your PATH.

Module Reference

Driver for PCO Pixelfly cameras.

class instrumental.drivers.cameras.pixelfly.Pixelfly(inst=None, **kwds)
cancel_capture()

Cancels a capture sequence, cleaning up and stopping the camera

close()

Clean up memory and close the camera.

get_captured_image(timeout='1s', copy=True, **kwds)

Get the image array(s) from the last capture sequence.

Returns an image numpy array (or tuple of arrays for a multi-exposure sequence). The array has shape (height, width) for grayscale images, and (height, width, 3) for RGB images. Typically the dtype will be uint8, or sometimes uint16 in the case of 16-bit monochromatic cameras.

Parameters
  • timeout (Quantity([time]) or None, optional) – Max time to wait for wait for the image data to be ready. If None, will block forever. If timeout is exceeded, a TimeoutError will be raised.

  • copy (bool, optional) – Whether to copy the image memory or directly reference the underlying buffer. It is recommended to use True (the default) unless you know what you’re doing.

grab_image(timeout='1s', copy=True, **kwds)

Perform a capture and return the resulting image array(s).

This is essentially a convenience function that calls start_capture() then get_captured_image(). See get_captured_image() for information about the returned array(s).

Parameters
  • timeouts (Quantity([time]) or None, optional) – Max time to wait for wait for the image data to be ready. If None, will block forever. If timeout is exceeded, a TimeoutError will be raised.

  • copy (bool, optional) – Whether to copy the image memory or directly reference the underlying buffer. It is recommended to use True (the default) unless you know what you’re doing.

  • include (You can specify other parameters of the capture as keyword arguments. These) –

  • n_frames (int) – Number of exposures in the sequence

  • vbin (int) – Vertical binning

  • hbin (int) – Horizontal binning

  • exposure_time (Quantity([time])) – Duration of each exposure

  • width (int) – Width of the ROI

  • height (int) – Height of the ROI

  • cx (int) – X-axis center of the ROI

  • cy (int) – Y-axis center of the ROI

  • left (int) – Left edge of the ROI

  • right (int) – Right edge of the ROI

  • top (int) – Top edge of the ROI

  • bot (int) – Bottom edge of the ROI

latest_frame(copy=True)

Get the latest image frame in live mode.

Returns the image array received on the most recent successful call to wait_for_frame().

Parameters

copy (bool, optional) – Whether to copy the image memory or directly reference the underlying buffer. It is recommended to use True (the default) unless you know what you’re doing.

quantum_efficiency(self, wavlen, high_gain=False)

Fractional quantum efficiency of the sensor at a given wavelength

set_mode(shutter='single', trig='software', exposure='10ms', hbin=1, vbin=1, gain='low', depth=12)

Set the mode of the camera.

Parameters
  • shutter (str) – One of ‘single’, ‘double’, or ‘video’.

  • trig (str) – One of ‘software’ or ‘hardware’.

  • exposure (Quantity or str) – Exposure time. Up to 65.6 ms with microsecond resolution.

  • hbin (int) – Horizontal binning factor. Either 1 or 2.

  • vbin (int) – Vertical binning factor. Either 1 or 2.

  • gain (str) – Gain of camera. Either ‘low’ or ‘high’.

  • depth (int) – Bit depth of each pixel. Either 8 or 12.

start_capture(**kwds)

Start a capture sequence and return immediately.

Depending on your camera-specific shutter/trigger settings, this will either start the exposure immediately or ready the camera to start on an explicit (hardware or software) trigger.

It can be useful to invoke start_capture() and get_captured_image() explicitly if you expect the capture sequence to take a long time and you’d like to perform some operations while you wait for the camera:

>>> cam.start_capture()
>>> do_other_useful_stuff()
>>> arr = cam.get_captured_image()

See grab_image() for the set of available kwds.

start_live_video(**kwds)

Start live video mode.

Once live video mode has been started, images will automatically and continuously be acquired. You can check if the next frame is ready by using wait_for_frame(), and access the most recent image’s data with get_captured_image().

See grab_image() for the set of available kwds.

stop_live_video()

Stop live video mode.

wait_for_frame(timeout=None)

Wait until the next frame is ready (in live mode).

Blocks and returns True once the next frame is ready, False if the timeout was reached. Using a timeout of 0 simply polls to see if the next frame is ready.

Parameters

timeout (Quantity([time]), optional) – How long to wait for wait for the image data to be ready. If None (the default), will block forever.

Returns

frame_readyTrue if the next frame is ready, False if the timeout was reached.

Return type

bool

DEFAULT_KWDS = {'bot': None, 'cx': None, 'cy': None, 'exposure_time': <Quantity(10, 'millisecond')>, 'fix_hotpixels': False, 'gain': 'low', 'hbin': 1, 'height': None, 'left': None, 'n_frames': 1, 'right': None, 'shutter': 'single', 'top': None, 'trig': 'software', 'vbin': 1, 'width': None}
property bit_depth
property frame_time
property height

Height of the camera image in pixels

property last_exposure_time
property max_height

Max settable height of the camera image, given current binning/subpixel settings

property max_width

Max settable width of the camera image, given current binning/subpixel settings

property readout_time
property supports_5us_exposure
property supports_double_mode
property supports_hvga
property supports_ir_mode
property supports_qe
property supports_set_exposure
property supports_svga
property supports_vga2
property temperature

The temperature of the CCD.

property width

Width of the camera image in pixels