BioImager  4.9.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
microscope.abc.Camera Class Reference
Inheritance diagram for microscope.abc.Camera:
microscope.abc.TriggerTargetMixin microscope.abc.DataDevice microscope.abc.Device microscope.cameras.andorsdk3.AndorSDK3 microscope.cameras.atmcd.AndorAtmcd microscope.cameras.picam.PiCamera microscope.cameras.pvcam.PVCamera microscope.cameras.ximea.XimeaCamera microscope.simulators.SimulatedCamera microscope.simulators.stage_aware_camera.StageAwareCamera microscope.testsuite.devices.TestCamera

Public Member Functions

None __init__ (self, **kwargs)
 
 set_readout_mode (self, description)
 
 get_transform (self)
 
 set_transform (self, transform)
 
None set_exposure_time (self, float value)
 
float get_exposure_time (self)
 
float get_cycle_time (self)
 
typing.Tuple[int, int] get_sensor_shape (self)
 
microscope.Binning get_binning (self)
 
None set_binning (self, microscope.Binning binning)
 
microscope.ROI get_roi (self)
 
None set_roi (self, microscope.ROI roi)
 
- Public Member Functions inherited from microscope.abc.TriggerTargetMixin
microscope.TriggerMode trigger_mode (self)
 
microscope.TriggerType trigger_type (self)
 
None set_trigger (self, microscope.TriggerType ttype, microscope.TriggerMode tmode)
 
None trigger (self)
 
- Public Member Functions inherited from microscope.abc.DataDevice
 __del__ (self)
 
None abort (self)
 
None enable (self)
 
None disable (self)
 
None set_client (self, new_client)
 
None update_settings (self, settings, bool init=False)
 
None receiveClient (self, str client_uri)
 
 grab_next_data (self, bool soft_trigger=True)
 
None receiveData (self, data, timestamp)
 
- Public Member Functions inherited from microscope.abc.Device
bool get_is_enabled (self)
 
None initialize (self)
 
None shutdown (self)
 
None add_setting (self, name, dtype, get_func, set_func, values, typing.Optional[typing.Callable[[], bool]] readonly=None)
 
 get_setting (self, str name)
 
 get_all_settings (self)
 
None set_setting (self, str name, value)
 
 describe_setting (self, str name)
 
 describe_settings (self)
 

Public Attributes

 set_readout_mode
 
 get_roi
 
 set_roi
 
- Public Attributes inherited from microscope.abc.DataDevice
bool enabled = False
 
bool _fetch_thread = True
 
bool _dispatch_thread = True
 
None _fetch_thread_run = self._fetch_data()
 
- Public Attributes inherited from microscope.abc.Device
bool enabled = False
 

Static Public Attributes

list ALLOWED_TRANSFORMS = [p for p in itertools.product(*3 * [[False, True]])]
 
- Static Public Attributes inherited from microscope.abc.DataDevice
 set_setting = keep_acquiring(Device.set_setting)
 

Protected Member Functions

 _process_data (self, data)
 
 _set_readout_transform (self, new_transform)
 
typing.Tuple[int, int] _get_sensor_shape (self)
 
microscope.Binning _get_binning (self)
 
 _set_binning (self, microscope.Binning binning)
 
microscope.ROI _get_roi (self)
 
 _set_roi (self, microscope.ROI roi)
 
- Protected Member Functions inherited from microscope.abc.TriggerTargetMixin
None _do_trigger (self)
 
- Protected Member Functions inherited from microscope.abc.DataDevice
None _fetch_data (self)
 
 _send_data (self, client, data, timestamp)
 
None _dispatch_loop (self)
 
None _fetch_loop (self)
 
 _client (self)
 
 _client (self, val)
 
None _put (self, data, timestamp)
 
- Protected Member Functions inherited from microscope.abc.Device
 _do_disable (self)
 
 _do_enable (self)
 
None _do_shutdown (self)
 

Protected Attributes

list _readout_modes = ["default"]
 
int _readout_mode = 0
 
tuple _readout_transform = (False, False, False)
 
tuple _client_transform = (False, False, False)
 
tuple _transform = (False, False, False)
 
- Protected Attributes inherited from microscope.abc.DataDevice
 _fetch_thread = None
 
bool _fetch_thread_run = False
 
bool _using_callback = False
 
list _clientStack = []
 
 _liveClients = set()
 
 _dispatch_thread = None
 
 _dispatch_buffer = queue.Queue(maxsize=buffer_length)
 
bool _acquiring = False
 
 _new_data_condition = threading.Condition()
 
 _client = None
 
tuple _new_data = (data, timestamp)
 
- Protected Attributes inherited from microscope.abc.Device
dict _settings = {}
 

Detailed Description

Adds functionality to :class:`DataDevice` to support cameras.

Defines the interface for cameras.  Applies a transform to
acquired data in the processing step.

Definition at line 819 of file abc.py.

Constructor & Destructor Documentation

◆ __init__()

None microscope.abc.Camera.__init__ ( self,
** buffer_length )
Derived.__init__ must call this at some point.

Reimplemented from microscope.abc.DataDevice.

Reimplemented in microscope.cameras.picam.PiCamera, microscope.cameras.ximea.XimeaCamera, microscope.simulators.SimulatedCamera, microscope.simulators.stage_aware_camera.StageAwareCamera, and microscope.testsuite.devices.TestCamera.

Definition at line 829 of file abc.py.

829 def __init__(self, **kwargs) -> None:
830 super().__init__(**kwargs)
831 # A list of readout mode descriptions.
832 self._readout_modes = ["default"]
833 # The index of the current readout mode.
834 self._readout_mode = 0
835 # Transforms to apply to data (fliplr, flipud, rot90)
836 # Transform to correct for readout order.
837 self._readout_transform = (False, False, False)
838 # Transform supplied by client to correct for system geometry.
839 self._client_transform = (False, False, False)
840 # Result of combining client and readout transforms
841 self._transform = (False, False, False)
842 # A transform provided by the client.
843 self.add_setting(
844 "transform",
845 "enum",
846 lambda: Camera.ALLOWED_TRANSFORMS.index(self._transform),
847 lambda index: self.set_transform(Camera.ALLOWED_TRANSFORMS[index]),
848 Camera.ALLOWED_TRANSFORMS,
849 )
850 self.add_setting(
851 "readout mode",
852 "enum",
853 lambda: self._readout_mode,
854 self.set_readout_mode,
855 lambda: self._readout_modes,
856 )
857 self.add_setting("roi", "tuple", self.get_roi, self.set_roi, None)
858

Member Function Documentation

◆ _get_binning()

microscope.Binning microscope.abc.Camera._get_binning ( self)
protected
Return the current binning.

Reimplemented in microscope.cameras.andorsdk3.AndorSDK3, microscope.cameras.atmcd.AndorAtmcd, microscope.cameras.picam.PiCamera, microscope.cameras.pvcam.PVCamera, microscope.cameras.ximea.XimeaCamera, and microscope.simulators.SimulatedCamera.

Definition at line 929 of file abc.py.

929 def _get_binning(self) -> microscope.Binning:
930 """Return the current binning."""
931 pass
932

◆ _get_roi()

microscope.ROI microscope.abc.Camera._get_roi ( self)
protected
Return the ROI as it is on hardware.

Reimplemented in microscope.cameras.andorsdk3.AndorSDK3, microscope.cameras.atmcd.AndorAtmcd, microscope.cameras.picam.PiCamera, microscope.cameras.pvcam.PVCamera, microscope.cameras.ximea.XimeaCamera, and microscope.simulators.SimulatedCamera.

Definition at line 957 of file abc.py.

957 def _get_roi(self) -> microscope.ROI:
958 """Return the ROI as it is on hardware."""
959 raise NotImplementedError()
960

◆ _get_sensor_shape()

typing.Tuple[int, int] microscope.abc.Camera._get_sensor_shape ( self)
protected
Return a tuple of `(width, height)` indicating shape in pixels.

Reimplemented in microscope.cameras.andorsdk3.AndorSDK3, microscope.cameras.atmcd.AndorAtmcd, microscope.cameras.picam.PiCamera, microscope.cameras.pvcam.PVCamera, microscope.cameras.ximea.XimeaCamera, and microscope.simulators.SimulatedCamera.

Definition at line 916 of file abc.py.

916 def _get_sensor_shape(self) -> typing.Tuple[int, int]:
917 """Return a tuple of `(width, height)` indicating shape in pixels."""
918 pass
919

◆ _process_data()

microscope.abc.Camera._process_data ( self,
data )
protected
Apply self._transform to data.

Reimplemented from microscope.abc.DataDevice.

Definition at line 859 of file abc.py.

859 def _process_data(self, data):
860 """Apply self._transform to data."""
861 flips = (self._transform[0], self._transform[1])
862 rot = self._transform[2]
863
864 # Choose appropriate transform based on (flips, rot).
865 # Do rotation
866 data = numpy.rot90(data, rot)
867 # Flip
868 data = {
869 (0, 0): lambda d: d,
870 (0, 1): numpy.flipud,
871 (1, 0): numpy.fliplr,
872 (1, 1): lambda d: numpy.fliplr(numpy.flipud(d)),
873 }[flips](data)
874 return super()._process_data(data)
875

◆ _set_binning()

microscope.abc.Camera._set_binning ( self,
microscope.Binning binning )
protected
Set binning along both axes.  Return `True` if successful.

Reimplemented in microscope.cameras.andorsdk3.AndorSDK3, microscope.cameras.atmcd.AndorAtmcd, microscope.cameras.picam.PiCamera, microscope.cameras.pvcam.PVCamera, microscope.cameras.ximea.XimeaCamera, and microscope.simulators.SimulatedCamera.

Definition at line 942 of file abc.py.

942 def _set_binning(self, binning: microscope.Binning):
943 """Set binning along both axes. Return `True` if successful."""
944 pass
945

◆ _set_readout_transform()

microscope.abc.Camera._set_readout_transform ( self,
new_transform )
protected
Update readout transform and update resultant transform.

Definition at line 897 of file abc.py.

897 def _set_readout_transform(self, new_transform):
898 """Update readout transform and update resultant transform."""
899 self._readout_transform = [bool(int(t)) for t in new_transform]
900 self.set_transform(self._client_transform)
901

◆ _set_roi()

microscope.abc.Camera._set_roi ( self,
microscope.ROI roi )
protected
Set the ROI on the hardware.  Return `True` if successful.

Reimplemented in microscope.cameras.andorsdk3.AndorSDK3, microscope.cameras.atmcd.AndorAtmcd, microscope.cameras.picam.PiCamera, microscope.cameras.pvcam.PVCamera, microscope.cameras.ximea.XimeaCamera, and microscope.simulators.SimulatedCamera.

Definition at line 970 of file abc.py.

970 def _set_roi(self, roi: microscope.ROI):
971 """Set the ROI on the hardware. Return `True` if successful."""
972 return False
973

◆ get_binning()

microscope.Binning microscope.abc.Camera.get_binning ( self)
Return the current binning corrected for transform.

Definition at line 933 of file abc.py.

933 def get_binning(self) -> microscope.Binning:
934 """Return the current binning corrected for transform."""
935 binning = self._get_binning()
936 if self._transform[2]:
937 # 90 degree rotation
938 binning = microscope.Binning(binning[1], binning[0])
939 return binning
940

◆ get_cycle_time()

float microscope.abc.Camera.get_cycle_time ( self)
Return the cycle time in seconds.

Reimplemented in microscope.cameras.andorsdk3.AndorSDK3, microscope.cameras.atmcd.AndorAtmcd, microscope.cameras.picam.PiCamera, microscope.cameras.pvcam.PVCamera, microscope.cameras.ximea.XimeaCamera, and microscope.simulators.SimulatedCamera.

Definition at line 911 of file abc.py.

911 def get_cycle_time(self) -> float:
912 """Return the cycle time in seconds."""
913 pass
914

◆ get_exposure_time()

float microscope.abc.Camera.get_exposure_time ( self)
Return the current exposure time in seconds.

Reimplemented in microscope.cameras.andorsdk3.AndorSDK3, microscope.cameras.atmcd.AndorAtmcd, microscope.cameras.picam.PiCamera, microscope.cameras.pvcam.PVCamera, microscope.cameras.ximea.XimeaCamera, and microscope.simulators.SimulatedCamera.

Definition at line 907 of file abc.py.

907 def get_exposure_time(self) -> float:
908 """Return the current exposure time in seconds."""
909 pass
910

◆ get_roi()

microscope.ROI microscope.abc.Camera.get_roi ( self)
Return current ROI.

Definition at line 961 of file abc.py.

961 def get_roi(self) -> microscope.ROI:
962 """Return current ROI."""
963 roi = self._get_roi()
964 if self._transform[2]:
965 # 90 degree rotation
966 roi = microscope.ROI(roi[1], roi[0], roi[3], roi[2])
967 return roi
968

◆ get_sensor_shape()

typing.Tuple[int, int] microscope.abc.Camera.get_sensor_shape ( self)
Return a tuple of `(width, height)` corrected for transform.

Definition at line 920 of file abc.py.

920 def get_sensor_shape(self) -> typing.Tuple[int, int]:
921 """Return a tuple of `(width, height)` corrected for transform."""
922 shape = self._get_sensor_shape()
923 if self._transform[2]:
924 # 90 degree rotation
925 shape = (shape[1], shape[0])
926 return shape
927

◆ get_transform()

microscope.abc.Camera.get_transform ( self)
Return the current transform without readout transform.

Definition at line 880 of file abc.py.

880 def get_transform(self):
881 """Return the current transform without readout transform."""
882 return self._client_transform
883

◆ set_binning()

None microscope.abc.Camera.set_binning ( self,
microscope.Binning binning )
Set binning along both axes.  Return `True` if successful.

Definition at line 946 of file abc.py.

946 def set_binning(self, binning: microscope.Binning) -> None:
947 """Set binning along both axes. Return `True` if successful."""
948 h_bin, v_bin = binning
949 if self._transform[2]:
950 # 90 degree rotation
951 binning = microscope.Binning(v_bin, h_bin)
952 else:
953 binning = microscope.Binning(h_bin, v_bin)
954 return self._set_binning(binning)
955

◆ set_exposure_time()

None microscope.abc.Camera.set_exposure_time ( self,
float value )
Set the exposure time on the device in seconds.

Reimplemented in microscope.cameras.andorsdk3.AndorSDK3, microscope.cameras.atmcd.AndorAtmcd, microscope.cameras.picam.PiCamera, microscope.cameras.pvcam.PVCamera, microscope.cameras.ximea.XimeaCamera, and microscope.simulators.SimulatedCamera.

Definition at line 903 of file abc.py.

903 def set_exposure_time(self, value: float) -> None:
904 """Set the exposure time on the device in seconds."""
905 pass
906

◆ set_readout_mode()

microscope.abc.Camera.set_readout_mode ( self,
description )
Set the readout mode and _readout_transform.

Reimplemented in microscope.cameras.pvcam.PVCamera.

Definition at line 876 of file abc.py.

876 def set_readout_mode(self, description):
877 """Set the readout mode and _readout_transform."""
878 pass
879

◆ set_roi()

None microscope.abc.Camera.set_roi ( self,
microscope.ROI roi )
Set the ROI according to the provided rectangle.

Return True if ROI set correctly, False otherwise.

Definition at line 974 of file abc.py.

974 def set_roi(self, roi: microscope.ROI) -> None:
975 """Set the ROI according to the provided rectangle.
976
977 Return True if ROI set correctly, False otherwise.
978 """
979 maxw, maxh = self.get_sensor_shape()
980 binning = self.get_binning()
981 left, top, width, height = roi
982 if not width: # 0 or None
983 width = maxw // binning.h
984 if not height: # 0 or None
985 height = maxh // binning.v
986 if self._transform[2]:
987 roi = microscope.ROI(left, top, height, width)
988 else:
989 roi = microscope.ROI(left, top, width, height)
990 return self._set_roi(roi)
991
992

◆ set_transform()

microscope.abc.Camera.set_transform ( self,
transform )
Combine provided transform with readout transform.

Definition at line 884 of file abc.py.

884 def set_transform(self, transform):
885 """Combine provided transform with readout transform."""
886 if isinstance(transform, str):
887 transform = literal_eval(transform)
888 self._client_transform = transform
889 lr, ud, rot = (
890 self._readout_transform[i] ^ transform[i] for i in range(3)
891 )
892 if self._readout_transform[2] and self._client_transform[2]:
893 lr = not lr
894 ud = not ud
895 self._transform = (lr, ud, rot)
896

Member Data Documentation

◆ _client_transform

tuple microscope.abc.Camera._client_transform = (False, False, False)
protected

Definition at line 839 of file abc.py.

◆ _readout_mode

microscope.abc.Camera._readout_mode = 0
protected

Definition at line 834 of file abc.py.

◆ _readout_modes

microscope.abc.Camera._readout_modes = ["default"]
protected

Definition at line 832 of file abc.py.

◆ _readout_transform

tuple microscope.abc.Camera._readout_transform = (False, False, False)
protected

Definition at line 837 of file abc.py.

◆ _transform

tuple microscope.abc.Camera._transform = (False, False, False)
protected

Definition at line 841 of file abc.py.

◆ ALLOWED_TRANSFORMS

list microscope.abc.Camera.ALLOWED_TRANSFORMS = [p for p in itertools.product(*3 * [[False, True]])]
static

Definition at line 827 of file abc.py.

◆ get_roi

microscope.abc.Camera.get_roi

Definition at line 857 of file abc.py.

◆ set_readout_mode

microscope.abc.Camera.set_readout_mode

Reimplemented in microscope.cameras.pvcam.PVCamera.

Definition at line 854 of file abc.py.

◆ set_roi

microscope.abc.Camera.set_roi

Definition at line 857 of file abc.py.


The documentation for this class was generated from the following file: