Package: pco
The Python packagepcois a powerful and easy to use high level Software Development Kit (SDK)
for working with PCO cameras. It contains everything needed for camera setup, image acquistion,
readout and color conversion.The high-level class architecture makes it very easy to integrate PCO cameras into your own
software, while still having access to the underlying pco.sdk and pco.recorder interface for a
detailed control of all possible functionalities.Documentation:ManualWebsite:https://www.excelitas.com/product-category/pcoSupport:support.pco@excelitas.comInstallationInstall from pypi (recommended):$ pip install pcoFor cameras with USB interface on linux you will need to add usb rules to the system.
This can be done with executing the following command (sudopermissions required):[!-f"/etc/udev/rules.d/pco_usb.rules"]&&sudomkdir-p"/etc/udev/rules.d"&&echo'SUBSYSTEM=="usb" , ATTR{idVendor}=="1cb2" , GROUP="video" , MODE="0666" , SYMLINK+="pco_usb_camera%n"'|sudotee/etc/udev/rules.d/pco_usb.rules>/dev/null&&udevadmtrigger||trueBasic Usageimportpcoimportmatplotlib.pyplotaspltwithpco.Camera()ascam:cam.record(mode="sequence")image,meta=cam.image()plt.imshow(image,cmap='gray')plt.show()Recorder ModesDepending on your workflow you can choose between different recording modes.Some modes are blocking, i.e. therecord()function waits until recording is finished, some are non-blocking.
Some of them are storing the images in memory, the others directly as file(s) on the disk.
However, for the recorder modes which store the images as files,
accessing the recorded images is identical with the modes which store the images in memory.record modesModeStorageBlockingDescriptionsequenceMemoryyesRecord a sequence of images.sequence non blockingMemorynoRecord a sequence of images, do not wait until record is finished.ring bufferMemorynoContinuously record images in a ringbuffer, once the buffer is full, old images are overwritten.fifoMemorynoRecord images in fifo mode, i.e. you will always read images sequentially and once the buffer is full, recording will pause until older images have been read.sequence dpcoreMemoryyesSame assequence, but with DotPhoton preparation enabled.sequence non blocking dpcoreMemorynoSame assequence_non_blocking, but with DotPhoton preparation enabled.ring buffer dpcoreMemorynoSame asring_buffer, but with DotPhoton preparation enabled.fifo dpcoreMemorynoSame asfifo, but with DotPhoton preparation enabled.tifFilenoRecord images directly as tif files.multitifFilenoRecord images directly as one or more multitiff file(s).pcorawFilenoRecord images directly as one pcoraw file.dicomFilenoRecord images directly as dicom files.multidicomFilenoRecord images directly as one or more multi-dicom file(s).camram segmentRamnoRecord images and stop if cam ram segment is fullcamram ringRamnoRecord images and use cam ram segment as ring bufferImage FormatsAll image data is always transferred as 2D or 3D numpy array.
Besides the standard 16 bit raw image data you also have the possibility to get your images in different formats,
shown in the table below.The format is selected when calling theimage()/images()/image_average()functions of the Camera class.
The image data is stored as numpy array, which enables you to work with it in the most pythonic way.image formatsFormatDescriptionMono8,mono8Get image as 8 bit grayscale data.Mono16,mono16,raw16,bw16Get image as 16 bit grayscale/raw data.BGR8,bgrGet image as 24 bit color data in bgr format.RGB8,rgbGet image as 24 bit color data in rgb format.BGRA8,bgra8,bgraGet image as 32 bit color data (with alpha channel) in bgra format.RGBA8,rgba8,rgbaGet image as 32 bit color data (with alpha channel) in rgba format.BGR16,bgr16Get image as 48 bit color data in bgr format (only possible for color cameras).RGB16,rgb16Get image as 48 bit color data in rgb format (only possible for color cameras).LoggingLogging is implemented according to the python logging package (https://docs.python.org/3/library/logging.html).
Supported logging levels are:ERRORWARNINGINFODEBUGlogger=logging.getLogger("pco")logger.setLevel(logging.INFO)logger.addHandler(pco.stream_handler)...[2023-10-1616:33:10,450][3.930s][sdk]open_camera_ex:OK....[2023-10-1616:33:13,485][0.001s][rec]copy_image:OK....Documentation (overview)The full Documentation can be found in themanualThe pco.Camera class offers the following methods:__init()__Open and initializes a camera with its default configuration.__exit()__Close the camera and cleans up everything (e.g. end of with-statement).close()Close the camera and cleans up everything.default_configuration()Set default configuration to the camerarecord()Initialize and start the recording of images.stop()Stop the current recording.wait_for_first_image()Wait until the first image has been recorded.wait_for_new_image()Wait until a new image has been recorded.get_convert_control()Get current color convert settings.set_convert_control()Set new color convert settings.load_lut()Set the lut file for the convert control setting.adapt_white_balance()Do a white-balance according to a transferred image.image()Read a recorded image as numpy array.images()Read a series of recorded images as a list of numpy arrays.image_average()Read an averaged image (averaged over all recorded images) as numpy array.switch_to_camram()Set camram segment for read via image functions.set_camram_allocation()Set allocation distribution of camram segments.The pco.Camera class has the following properties:camera_nameget the camera name.camera_serialget the serial number of the camera.is_recordingget a flag to indicate if the camera is currently recording.is_colorget a flag to indicate if the camera is a color camera.recorded_image_countget the number of currently recorded images.configurationget/set the camera configuration.descriptionget the (static) camera description parameters.exposure_timeget/set the exposure time (in seconds).delay_timeget/set the delay time (in seconds).has_ramget flag that indicates camram support of the camera.camram_segmentget segment number of active camram segmentcamram_max_imagesget number of images that can be stored in the active camram segmentcamram_num_imagesget number of images that are available in the active camram segmentThe pco.Camera class holds the following objects:sdkoffer direct access to all underlying functions of the pco.sdk.recoffer direct access to all underlying functions of the pco.recorder.convoffer direct access to all underlying functions of the pco.convert according to the selected image format.