Camera
- class caqtus.device.camera.Camera(
- roi: RectangularROI,
- timeout,
- external_trigger: bool,
-
Define the interface for a camera instrument.
This is an abstract class that must be subclassed to implement a specific camera. Subclasses must implement the
update_parameters()andacquire()methods.- roi
A rectangular subset of the sensor that defines the region of interest.
Images returned by the camera must be of the same size as the region of interest. Some camera models allow to define the region of interest before even fetching the image from the instrument. This is the recommended way to crop the region of interest, as it will reduce the amount of data transferred from the camera to the computer. If the camera does not support defining the region of interest before fetching the image, the region of interest should be cropped after the image is acquired and before it is returned to the user. This attribute can only be set with the
__init__()method.
- timeout
The maximum time in seconds that the camera must wait for an external trigger signal before raising a
CameraTimeoutError.- Type:
- external_trigger
Indicates if the camera is waiting for an external trigger signal to acquire an image.
If this is set to True, the camera will wait for the trigger signal before acquiring an image. If this is set to False, the camera will acquire an image as soon as possible after the acquisition is started. This attribute can only be set with the
__init__()method.- Type:
- sensor_width
A class attribute that defines the width of the sensor in pixels.
This attribute must be set in the subclass implementation.
- Type:
ClassVar[int]
- sensor_height
A class attribute that defines the height of the sensor in pixels.
This attribute must be set in the subclass implementation.
- Type:
ClassVar[int]
- abstractmethod update_parameters(timeout: float, *args, **kwargs) None
Update the camera parameters between acquisitions.
It is undefined what should happen if this method is called while the camera is acquiring images.
- abstractmethod acquire( ) AbstractContextManager[Iterator[ndarray[tuple[Width, Height], dtype[T]]]]
Acquire images with the given exposure times.
- Returns:
A context manager that yields an iterator of images. When the context manager is entered, the camera starts the acquisition of the number of images specified by the length of the exposures list.
Iterating over the iterator returned by the context manager will yield the images as they are acquired by the camera. It is recommended to yield the images as they are acquired, and not to wait for all the images to be acquired before returning them. This allows to do some processing on the images and to react to them while the camera is still acquiring the next ones.
When the context manager exits, the camera stops the acquisition.
Note that not all images might have been acquired when the context manager exits, if not all images have been consumed by the user due to an exception or a break in the with statement.
- Raises:
CameraTimeoutError – In the iterator if the camera could not acquire an image after the timeout specified by the method
update_parameters().
Example
This demonstrates how to use this method to take images:
with camera.acquire(exposures=[0.1, 0.5, 1.0]) as images: for image in images: print(image)