Implementing Cameras
To allow acquisition from a camera or other imaging system, implement a sub-class of the GenericCamera class in ‘src/cameras/generic_camera.py’.
There are several examples available in the folder for different cameras. It is not necessary to implement all of the methods in the GenericCamera class, for example if the frame rate methods are not implemented, it will simply not be possible to adjust the frame rate in the GUI, but images will still be acquired.
To produce a minimal working camera, the following methods need to be implemented:
open_camera
The function should do whatever is necessary to connect to the camera and prepare for image acquisition. The function accepts a single argument for the camera number, simply ignore this if not relevant for your camera. If the camera is successfully opened, the function must set:
self.camera_open = True
close_camera
Place any calls here that are needed to disconnect from the camera. If the camera is successfully closed, the function must set:
self.camera_open = False
get_image
This method will be called by CAS_GUI to grab images from the camera. This
method must return either an image as a numpy array or None if any
image could not be acquired.
Gain, Exposure and Frame Rate
If these functions are not implemented, then by default it will not be possible to change the gain, exposure or frame rate in the GUI, and the
functions is_frame_rate_enabled(), is_gain_enabled() and is_exposure_enabled() will return False.
To enable frame rate, expsoure or gain, override these functions to return True.
Then implement functions to get and set the values. For example, for the frame rate, implement get_frame_rate()
which should return the current frame rate, and set_frame_rate(frameRate) which takes one parameter (frameRate) and should attempt to set it. These will then be used by CAS GUI to
implement user-requsted changes. Finally, also implement
get_frame_rate_range() which should return a tuple of the minimum and maximum values that can be set. This is used by CAS GUI to set the range of the frame rate slider and spin box. The same functions
can be implemented for exposure and gain (replacing ‘frame_rate’ with ‘exposure’ and ‘gain’).