def getImageSize(self, name): """Read the image size from the camera.""" roi = self._proxy.get_roi() # left, bottom, right, top if not isinstance(roi, ROI): cockpit.util.logger.log.warning("%s returned tuple not ROI()" % self.name) roi = ROI(*roi) binning = self._proxy.get_binning() if not isinstance(binning, Binning): cockpit.util.logger.log.warning("%s returned tuple not Binning()" % self.name) binning = Binning(*binning) return (roi.width//binning.h, roi.height//binning.v)
def __init__(self, **kwargs): super().__init__(**kwargs) # Binning and ROI self._roi = ROI(0, 0, 512, 512) self._binning = Binning(1, 1) # Function used to generate test image self._image_generator = _ImageGenerator() self.add_setting('image pattern', 'enum', self._image_generator.method, self._image_generator.set_method, self._image_generator.get_methods) self.add_setting('image data type', 'enum', self._image_generator.data_type, self._image_generator.set_data_type, self._image_generator.get_data_types) self.add_setting('display image number', 'bool', lambda: self._image_generator.numbering, self._image_generator.enable_numbering, None) # Software buffers and parameters for data conversion. self._a_setting = 0 self.add_setting('a_setting', 'int', lambda: self._a_setting, lambda val: setattr(self, '_a_setting', val), lambda: (1, 100)) self._error_percent = 0 self.add_setting('_error_percent', 'int', lambda: self._error_percent, self._set_error_percent, lambda: (0, 100)) self._gain = 0 self.add_setting('gain', 'int', lambda: self._gain, self._set_gain, lambda: (0, 8192)) # Enum-setting tests self._intEnum = CamEnum.A self.add_setting('intEnum', 'enum', lambda: self._intEnum, lambda val: setattr(self, '_intEnum', val), CamEnum) self._dictEnum = 0 self.add_setting('dictEnum', 'enum', lambda: self._dictEnum, lambda val: setattr(self, '_dictEnum', val), { 0: 'A', 8: 'B', 13: 'C', 22: 'D' }) self._listEnum = 0 self.add_setting('listEnum', 'enum', lambda: self._listEnum, lambda val: setattr(self, '_listEnum', val), ['A', 'B', 'C', 'D']) self._tupleEnum = 0 self.add_setting('tupleEnum', 'enum', lambda: self._tupleEnum, lambda val: setattr(self, '_tupleEnum', val), ('A', 'B', 'C', 'D')) self._acquiring = False self._exposure_time = 0.1 self._triggered = 0 # Count number of images sent since last enable. self._sent = 0
def _get_roi(self): return ROI(self._aoi_left.get_value(), self._aoi_top.get_value(), self._aoi_width.get_value(), self._aoi_height.get_value())
def _get_roi(self): """Return the current ROI (left, top, width, height).""" return ROI(0, 0, 512, 512)
def __init__(self, *args, **kwargs): super(PiCamera, self).__init__(**kwargs) #example parameter to allow setting. # self.add_setting('_error_percent', 'int', # lambda: self._error_percent, # self._set_error_percent, # lambda: (0, 100)) self._acquiring = False self._exposure_time = 0.1 self._triggered = False self.camera = None # Region of interest. self.roi = ROI(None, None, None, None) # Cycle time self.exposure_time = 0.001 # in seconds self.cycle_time = self.exposure_time #initialise in soft trigger mode self._trigger_type = microscope.TriggerType.SOFTWARE #setup hardware triggerline GPIO.setmode(GPIO.BCM) #GPIO trigger line is an input GPIO.setup(GPIO_Trigger, GPIO.IN) #GPIO control over camera LED is an output GPIO.setup(GPIO_CAMLED, GPIO.OUT) #add trigger to settings trg_source_names = [x.name for x in TrgSourceMap] #set up queue to store images as they are acquired self._queue = queue.Queue() self._awb_modes = picamera.PiCamera.AWB_MODES self._iso_modes = [0, 100, 200, 320, 400, 500, 640, 800] def _trigger_source_setter(index: int) -> None: trigger_type = TrgSourceMap[trg_source_names[index]].value self.set_trigger(trigger_type, self.trigger_mode) self.add_setting( "trig source", "enum", lambda: TrgSourceMap(self._trigger_type).name, _trigger_source_setter, trg_source_names, ) self.add_setting( "AWB", "enum", lambda: self._awb_modes[self.get_awb_mode()], lambda awb: self.set_awb_mode(awb), values=(list(self._awb_modes.keys())), ) self.add_setting( "ISO", "enum", lambda: self._iso_modes.index(self.camera.iso), lambda iso: self.set_iso_mode(iso), values=(self._iso_modes), ) # self.add_setting( # "pixel size", # "float", # lambda: self._pixel_size, # lambda pxsz: setattr(self, "_pixel_size", pxsz), # # technically should be: (nextafter(0.0, inf), nextafter(inf, 0.0)) # values=(0.0, float("inf")), # ) self.initialize()
def _set_roi(self, left, top, width, height): """Set the ROI to (left, tip, width, height).""" self.roi = ROI(left, top, width, height)