Base Camera Model

Base Camera Model

Camera class with the base methods. Having a base class exposes the general API for working with cameras. This file is important to keep track of the methods which are exposed to the View. The class BaseCamera should be subclassed when developing new Models for other cameras. This ensures that all the methods are automatically inherited and there are no breaks downstream.

Conventions

Images are 0-indexed. Therefore, a camera with (1024px X 1024px) will be used as img[0:1024, 0:1024] (remember Python leaves out the last value in the slice.

Region of Interest is specified with the coordinates of the corners. A full-frame with the example above would be given by X=[0,1023], Y=[0,1023]. Be careful, since the maximum width (or height) of the camera is 1024.

The camera keeps track of the coordinates of the initial pixel. For full-frame, this will always be [0,0]. When croping, the corner-pixel will change. It is very important to keep track of this value when building a GUI, since after the first crop, if the user wants to crop even further, the information has to be referenced to the already cropped area.

Notes

IMPORTANT Whatever new function is implemented in a specific model, it should be first declared in the BaseCamera class. In this way the other models will have access to the method and the program will keep running (perhaps with the wrong behavior though).

class experimentor.models.devices.cameras.base_camera.BaseCamera(camera, initial_config=None)[source]

Base Camera model. All camera models should inherit from this model in order to extend functionality. There are some assumptions regarding how to update different settings such as exposure, gain, region of interest.

Parameters:camera (str or int) – Parameter to identify the camera when loading or initializing it.
AQUISITION_MODE

Different acquisition modes: Continuous, Single, Keep last.

Type:dict
cam_num

This parameter will be used to identify the camera when loading or initializing it.

Type:str or int
running

Whether the camera is running or not

Type:bool
max_width

Maximum width, in pixels

Type:int
max_height

Maximum height, in pixels

Type:int
data_type

The data type of the images generated by the camera. This can be used to allocate the correct amount of memory in buffers, or to reduce data before displaying it. For example, np.uint16.

Type:np data type
temp_image

It stores the last image acquired by the camera. Useful for user interfaces that need to display images at a rate different than the acquisition rate.

Type:np.array
ACQUISITION_MODE = {0: 'Single', 1: 'Continuous', 2: 'Keep Last'}
MODE_CONTINUOUS = 1
MODE_LAST = 2
MODE_SINGLE_SHOT = 0
ROI

Sets up the ROI. Not all cameras are 0-indexed, so this is an important place to define the proper ROI.

vals : list or tuple
Organized as (X, Y), where the coordinates for the ROI would be X[0], X[1], Y[0], Y[1]
acquisition_mode

Single or continuous. :param int mode: One of self.MODE_CONTINUOUS, self.MODE_SINGLE_SHOT

Type:Set the readout mode of the camera
acquisition_ready()[source]

Checks if the acquisition in the camera is over.

binning

The binning of the camera if supported. Has to check if binning in X/Y can be different or not, etc.

The binning is specified as a list or tuple like: [X, Y], with the information of the binning in the X or Y direction.

camera = 'Base Camera Model'
ccd_height

Returns the CCD height in pixels this is equivalent to the max_height

ccd_width

Returns the CCD width in pixels this is equivalent to the max_width

clear_ROI()[source]

Clears the ROI by setting it to the maximum available area.

clear_binning()[source]

Clears the binning of the camera to its default value.

configure(properties: dict)[source]

Configure the camera based on a dictionary of properties.

Deprecated since version 0.3.0: By implementing features, this method is no longer required

exposure

Sets the exposure of the camera.

gain

Sets the gain on the camera, if possible

gain : float
The gain, depending on the camera it can be an integer, it can be specified in dB, etc.
initialize()[source]

Initializes the camera.

read_camera()[source]

Reads the camera and stores the image in the temp_image attribute

serial_number

Returns the serial number of the camera, or a way of identifying the camera in an experiment.

stop_acquisition()[source]

Stops the acquisition without closing the connection to the camera.

stop_camera()[source]

Stops the acquisition and closes the connection with the camera.

trigger_camera()[source]

Triggers the camera.