def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load objects
        self.camera = camera.Camera()
        self.microcontroller = microcontroller.Microcontroller_Simulation()

        self.streamHandler = core.StreamHandler()
        self.liveController = core.LiveController(self.camera,
                                                  self.microcontroller)
        self.imageSaver = core.ImageSaver()
        self.imageDisplay = core.ImageDisplay()
        '''
		# thread
		self.thread_multiPoint = QThread()
		self.thread_multiPoint.start()
		self.multipointController.moveToThread(self.thread_multiPoint)
		'''

        # open the camera
        # camera start streaming
        self.camera.open()
        self.camera.set_software_triggered_acquisition()
        self.camera.set_callback(self.streamHandler.on_new_frame)
        self.camera.enable_callback()

        # load widgets
        self.cameraSettingWidget = widgets.CameraSettingsWidget(
            self.camera, self.liveController)
        self.liveControlWidget = widgets.LiveControlWidget(
            self.streamHandler, self.liveController)
        self.recordingControlWidget = widgets.RecordingWidget(
            self.streamHandler, self.imageSaver)

        # layout widgets
        layout = QGridLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget, 0, 0)
        layout.addWidget(self.liveControlWidget, 1, 0)
        layout.addWidget(self.recordingControlWidget, 4, 0)

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        self.setCentralWidget(self.centralWidget)

        # load window
        self.imageDisplayWindow = core.ImageDisplayWindow()
        self.imageDisplayWindow.show()

        # make connections
        self.streamHandler.signal_new_frame_received.connect(
            self.liveController.on_new_frame)
        self.streamHandler.image_to_display.connect(self.imageDisplay.enqueue)
        self.streamHandler.packet_image_to_write.connect(
            self.imageSaver.enqueue)
        self.imageDisplay.image_to_display.connect(
            self.imageDisplayWindow.display_image
        )  # may connect streamHandler directly to imageDisplayWindow
示例#2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load objects
        self.internal_states = Internal_States()
        self.microcontroller = microcontroller.Microcontroller()
        self.navigationController = core.NavigationController(
            self.microcontroller)
        self.PDAFController = core_PDAF.PDAFController(self.internal_states)

        self.camera_1 = camera.Camera(sn='FW0200050063')  # tracking
        self.camera_2 = camera.Camera(sn='FW0200050068')  # fluorescence

        self.configurationManager = core.ConfigurationManager(
            filename=str(Path.home()) + "/configurations_PDAF.xml")

        self.streamHandler_1 = core.StreamHandler()
        self.liveController_1 = core.LiveController(self.camera_1,
                                                    self.microcontroller,
                                                    self.configurationManager,
                                                    control_illumination=False)
        self.imageSaver_1 = core.ImageSaver()

        self.streamHandler_2 = core.StreamHandler()
        self.liveController_2 = core.LiveController(self.camera_2,
                                                    self.microcontroller,
                                                    self.configurationManager,
                                                    control_illumination=True)
        self.imageSaver_2 = core.ImageSaver()

        self.twoCamerasPDAFCalibrationController = core_PDAF.TwoCamerasPDAFCalibrationController(
            self.camera_1, self.camera_2, self.navigationController,
            self.liveController_1, self.liveController_2,
            self.configurationManager)

        # open the camera
        # camera start streaming
        self.camera_1.open()
        self.camera_1.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera_1.set_callback(self.streamHandler_1.on_new_frame)
        self.camera_1.enable_callback()

        self.camera_2.open()
        self.camera_2.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera_2.set_callback(self.streamHandler_2.on_new_frame)
        self.camera_2.enable_callback()

        # load widgets
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)
        self.cameraSettingWidget_1 = widgets.CameraSettingsWidget(
            self.camera_1, self.liveController_1)
        self.liveControlWidget_1 = widgets.LiveControlWidget(
            self.streamHandler_1, self.liveController_1,
            self.configurationManager)
        self.cameraSettingWidget_2 = widgets.CameraSettingsWidget(
            self.camera_2, self.liveController_2)
        self.liveControlWidget_2 = widgets.LiveControlWidget(
            self.streamHandler_2, self.liveController_2,
            self.configurationManager)

        # layout widgets
        layout = QGridLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget_1, 0, 0)
        layout.addWidget(self.liveControlWidget_1, 1, 0)
        layout.addWidget(self.cameraSettingWidget_2, 0, 1)
        layout.addWidget(self.liveControlWidget_2, 1, 1)

        layout.addWidget(self.navigationWidget, 7, 0)

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        self.setCentralWidget(self.centralWidget)

        # load window
        self.imageDisplayWindow_1 = core.ImageDisplayWindow('camera 1')
        self.imageDisplayWindow_1.show()
        self.imageDisplayWindow_2 = core.ImageDisplayWindow('camera 2')
        self.imageDisplayWindow_2.show()

        # make connections
        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)

        self.streamHandler_1.signal_new_frame_received.connect(
            self.liveController_1.on_new_frame)
        self.streamHandler_1.image_to_display.connect(
            self.imageDisplayWindow_1.display_image)
        self.streamHandler_1.packet_image_to_write.connect(
            self.imageSaver_1.enqueue)
        #self.streamHandler_1.packet_image_for_tracking.connect(self.trackingController.on_new_frame)

        self.liveControlWidget_1.signal_newExposureTime.connect(
            self.cameraSettingWidget_1.set_exposure_time)
        self.liveControlWidget_1.signal_newAnalogGain.connect(
            self.cameraSettingWidget_1.set_analog_gain)
        self.liveControlWidget_1.update_camera_settings()

        self.streamHandler_2.signal_new_frame_received.connect(
            self.liveController_2.on_new_frame)
        self.streamHandler_2.image_to_display.connect(
            self.imageDisplayWindow_2.display_image)
        self.streamHandler_2.packet_image_to_write.connect(
            self.imageSaver_2.enqueue)

        self.liveControlWidget_2.signal_newExposureTime.connect(
            self.cameraSettingWidget_2.set_exposure_time)
        self.liveControlWidget_2.signal_newAnalogGain.connect(
            self.cameraSettingWidget_2.set_analog_gain)
        self.liveControlWidget_2.update_camera_settings()

        self.streamHandler_1.image_to_display.connect(
            self.PDAFController.register_image_from_camera_1)
        self.streamHandler_2.image_to_display.connect(
            self.PDAFController.register_image_from_camera_2)
	def __init__(self, is_simulation = False, *args, **kwargs):
		super().__init__(*args, **kwargs)

		# load objects
		if is_simulation:
			self.camera = camera.Camera_Simulation()
			self.microcontroller = microcontroller.Microcontroller_Simulation()
		else:
			self.camera = camera.Camera()
			self.microcontroller = microcontroller.Microcontroller()
		
		self.configurationManager = core.ConfigurationManager(filename=str(Path.home()) + "/configurations_platereader.xml")
		self.streamHandler = core.StreamHandler()
		self.liveController = core.LiveController(self.camera,self.microcontroller,self.configurationManager)
		self.navigationController = core.NavigationController(self.microcontroller)
		self.plateReaderNavigationController = core.PlateReaderNavigationController(self.microcontroller)
		self.autofocusController = core.AutoFocusController(self.camera,self.navigationController,self.liveController)
		self.plateReadingController = core_platereader.PlateReadingController(self.camera,self.plateReaderNavigationController,self.liveController,self.autofocusController,self.configurationManager)
		self.imageSaver = core.ImageSaver()

		# open the camera
		# camera start streaming
		self.camera.open()
		self.camera.set_software_triggered_acquisition() #self.camera.set_continuous_acquisition()
		self.camera.set_callback(self.streamHandler.on_new_frame)
		self.camera.enable_callback()

		# load widgets
		self.cameraSettingWidget = widgets.CameraSettingsWidget(self.camera,include_gain_exposure_time=False)
		self.liveControlWidget = widgets.LiveControlWidget(self.streamHandler,self.liveController,self.configurationManager,show_trigger_options=False,show_display_options=False)
		self.autofocusWidget = widgets.AutoFocusWidget(self.autofocusController)
		self.plateReaderAcquisitionWidget = widgets.PlateReaderAcquisitionWidget(self.plateReadingController,self.configurationManager,show_configurations=False)
		self.plateReaderNavigationWidget = widgets.PlateReaderNavigationWidget(self.plateReaderNavigationController)

		# layout widgets
		layout = QGridLayout() #layout = QStackedLayout()
		#layout.addWidget(self.cameraSettingWidget,0,0)
		layout.addWidget(self.liveControlWidget,1,0)
		layout.addWidget(self.plateReaderNavigationWidget,2,0)
		layout.addWidget(self.autofocusWidget,3,0)
		layout.addWidget(self.plateReaderAcquisitionWidget,4,0)
		
		# transfer the layout to the central widget
		self.centralWidget = QWidget()
		self.centralWidget.setLayout(layout)
		self.setCentralWidget(self.centralWidget)

		# load window
		self.imageDisplayWindow = core.ImageDisplayWindow()
		self.imageDisplayWindow.show()

		# make connections
		self.streamHandler.signal_new_frame_received.connect(self.liveController.on_new_frame)
		self.streamHandler.image_to_display.connect(self.imageDisplayWindow.display_image)
		self.streamHandler.packet_image_to_write.connect(self.imageSaver.enqueue)
		# self.plateReaderNavigationController.xPos.connect(self.navigationWidget.label_Xpos.setNum)
		# self.plateReaderNavigationController.yPos.connect(self.navigationWidget.label_Ypos.setNum)
		# self.plateReaderNavigationController.zPos.connect(self.navigationWidget.label_Zpos.setNum)
		self.autofocusController.image_to_display.connect(self.imageDisplayWindow.display_image)
		# self.plateReadingController.image_to_display.connect(self.imageDisplayWindow.display_image)
		self.plateReadingController.signal_current_configuration.connect(self.liveControlWidget.set_microscope_mode)
		self.plateReadingController.image_to_display.connect(self.imageDisplayWindow.display_image)
		self.liveControlWidget.signal_newExposureTime.connect(self.cameraSettingWidget.set_exposure_time)
		self.liveControlWidget.signal_newAnalogGain.connect(self.cameraSettingWidget.set_analog_gain)
		self.liveControlWidget.update_camera_settings()

		self.microcontroller.set_callback(self.plateReaderNavigationController.update_pos)
		self.plateReaderNavigationController.signal_homing_complete.connect(self.plateReaderNavigationWidget.slot_homing_complete)
		self.plateReaderNavigationController.signal_homing_complete.connect(self.plateReaderAcquisitionWidget.slot_homing_complete)
		self.plateReaderNavigationController.signal_current_well.connect(self.plateReaderNavigationWidget.update_current_location)
示例#4
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load objects
        self.camera = camera.Camera()
        self.microcontroller = microcontroller.Microcontroller_Simulation()

        self.configurationManager = core.ConfigurationManager()
        self.streamHandler = core_volumetric_imaging.StreamHandler(
            crop_width=500, crop_height=500)
        self.liveController = core.LiveController(self.camera,
                                                  self.microcontroller,
                                                  self.configurationManager)
        self.navigationController = core.NavigationController(
            self.microcontroller)
        self.autofocusController = core.AutoFocusController(
            self.camera, self.navigationController, self.liveController)
        self.multipointController = core.MultiPointController(
            self.camera, self.navigationController, self.liveController,
            self.autofocusController, self.configurationManager)
        self.trackingController = core.TrackingController(
            self.microcontroller, self.navigationController)
        self.imageSaver = core.ImageSaver()
        self.imageDisplay = core.ImageDisplay()

        # open the camera
        # camera start streaming
        self.camera.open()
        self.camera.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera.set_callback(self.streamHandler.on_new_frame)
        self.camera.enable_callback()

        # load widgets
        self.cameraSettingWidget = widgets.CameraSettingsWidget(
            self.camera, self.liveController)
        self.liveControlWidget = widgets.LiveControlWidget(
            self.streamHandler, self.liveController, self.configurationManager)
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)
        self.autofocusWidget = widgets.AutoFocusWidget(
            self.autofocusController)
        self.recordingControlWidget = widgets.RecordingWidget(
            self.streamHandler, self.imageSaver)
        self.trackingControlWidget = widgets.TrackingControllerWidget(
            self.streamHandler, self.trackingController)
        self.multiPointWidget = widgets.MultiPointWidget(
            self.multipointController, self.configurationManager)

        self.recordTabWidget = QTabWidget()
        self.recordTabWidget.addTab(self.recordingControlWidget,
                                    "Simple Recording")
        # self.recordTabWidget.addTab(self.trackingControlWidget, "Tracking")
        # self.recordTabWidget.addTab(self.multiPointWidget, "Multipoint Acquisition")

        # layout widgets
        layout = QGridLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget, 0, 0)
        layout.addWidget(self.liveControlWidget, 1, 0)
        # layout.addWidget(self.navigationWidget,2,0)
        # layout.addWidget(self.autofocusWidget,3,0)
        layout.addWidget(self.recordTabWidget, 4, 0)

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        self.setCentralWidget(self.centralWidget)

        # load window
        self.imageDisplayWindow = core.ImageDisplayWindow()
        self.imageArrayDisplayWindow = core_volumetric_imaging.ImageArrayDisplayWindow(
        )
        self.imageDisplayWindow.show()
        self.imageArrayDisplayWindow.show()

        # make connections
        self.streamHandler.signal_new_frame_received.connect(
            self.liveController.on_new_frame)
        self.streamHandler.image_to_display.connect(self.imageDisplay.enqueue)
        self.streamHandler.packet_image_to_write.connect(
            self.imageSaver.enqueue)
        self.streamHandler.packet_image_for_tracking.connect(
            self.trackingController.on_new_frame)
        self.streamHandler.packet_image_for_array_display.connect(
            self.imageArrayDisplayWindow.display_image)
        self.imageDisplay.image_to_display.connect(
            self.imageDisplayWindow.display_image
        )  # may connect streamHandler directly to imageDisplayWindow
        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)
        self.autofocusController.image_to_display.connect(
            self.imageDisplayWindow.display_image)
        # self.multipointController.image_to_display.connect(self.imageDisplayWindow.display_image)
        self.multipointController.signal_current_configuration.connect(
            self.liveControlWidget.set_microscope_mode)
        self.multipointController.image_to_display_multi.connect(
            self.imageArrayDisplayWindow.display_image)
        self.liveControlWidget.signal_newExposureTime.connect(
            self.cameraSettingWidget.set_exposure_time)
        self.liveControlWidget.signal_newAnalogGain.connect(
            self.cameraSettingWidget.set_analog_gain)
        self.liveControlWidget.update_camera_settings()
示例#5
0
    def __init__(self, is_simulation=False, *args, **kwargs):
        super().__init__(*args, **kwargs)

        channels = ['ch 1', 'ch 2']
        self.channels = channels

        self.imageDisplayWindow = {}
        for i in range(len(channels)):
            self.imageDisplayWindow[channels[i]] = core.ImageDisplayWindow(
                draw_crosshairs=True)

        # load objects
        self.camera = {}
        if is_simulation:
            for i in range(len(channels)):
                self.camera[channels[i]] = camera.Camera_Simulation(
                    sn=CAMERA_SN[channels[i]],
                    is_global_shutter=True,
                    rotate_image_angle=ROTATE_IMAGE_ANGLE,
                    flip_image=FLIP_IMAGE)
            self.microcontroller = microcontroller.Microcontroller_Simulation()
            self.microcontroller2 = microcontroller2.Microcontroller2_Simulation(
            )
        else:
            for i in range(len(channels)):
                self.camera[channels[i]] = camera.Camera(
                    sn=CAMERA_SN[channels[i]],
                    is_global_shutter=True,
                    rotate_image_angle=ROTATE_IMAGE_ANGLE,
                    flip_image=FLIP_IMAGE)
            self.microcontroller = microcontroller.Microcontroller_Simulation()
            self.microcontroller2 = microcontroller2.Microcontroller2()

        # open the camera
        for i in range(len(channels)):
            self.camera[channels[i]].open()
            self.camera[channels[i]].set_software_triggered_acquisition(
            )  #self.camera.set_continuous_acquisition()

        # configure the actuators
        self.microcontroller.configure_actuators()

        # navigation controller and widget
        self.navigationController = core.NavigationController(
            self.microcontroller)
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)

        self.configurationManager = {}
        self.streamHandler = {}
        self.liveController = {}
        self.imageSaver = {}

        self.cameraSettingWidget = {}
        self.liveControlWidget = {}
        self.cameraTabWidget = QTabWidget()

        for i in range(len(channels)):
            # controllers
            self.configurationManager[channels[i]] = core.ConfigurationManager(
                filename=str(Path.home()) + "/configurations_" + channels[i] +
                ".xml")
            self.streamHandler[channels[i]] = core.StreamHandler(
                display_resolution_scaling=DEFAULT_DISPLAY_CROP / 100)
            self.liveController[channels[i]] = core.LiveController(
                self.camera[channels[i]],
                self.microcontroller,
                self.configurationManager[channels[i]],
                use_internal_timer_for_hardware_trigger=False)
            self.imageSaver[channels[i]] = core.ImageSaver(
                image_format=Acquisition.IMAGE_FORMAT)
            # widgets
            self.cameraSettingWidget[
                channels[i]] = widgets.CameraSettingsWidget(
                    self.camera[channels[i]], include_gain_exposure_time=False)
            self.liveControlWidget[channels[i]] = widgets.LiveControlWidget(
                self.streamHandler[channels[i]],
                self.liveController[channels[i]],
                self.configurationManager[channels[i]])
            # self.recordingControlWidget[channels[i]] = widgets.RecordingWidget(self.streamHandler[channels[i]],self.imageSaver[channels[i]])
            self.cameraTabWidget.addTab(self.liveControlWidget[channels[i]],
                                        channels[i])
            # self.liveControlWidget[channels[i]].setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
            # self.liveControlWidget[channels[i]].resize(self.liveControlWidget[channels[i]].minimumSizeHint())
            # self.liveControlWidget[channels[i]].adjustSize()
        self.cameraTabWidget.resize(self.cameraTabWidget.minimumSizeHint())
        self.cameraTabWidget.adjustSize()

        # self.recordTabWidget = QTabWidget()
        # for i in range(len(channels)):
        # 	self.recordTabWidget.addTab(self.recordingControlWidget[channels[i]], "Simple Recording")
        self.multiCameraRecordingWidget = widgets.MultiCameraRecordingWidget(
            self.streamHandler, self.imageSaver, self.channels)

        # trigger control
        self.triggerControlWidget = widgets.TriggerControlWidget(
            self.microcontroller2)

        # layout widgets
        layout = QVBoxLayout()  #layout = QStackedLayout()
        # layout.addWidget(self.cameraSettingWidget)
        layout.addWidget(self.cameraTabWidget)
        layout.addWidget(self.triggerControlWidget)
        layout.addWidget(self.multiCameraRecordingWidget)
        # layout.addWidget(self.navigationWidget)
        # layout.addWidget(self.recordTabWidget)
        layout.addStretch()

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        # self.centralWidget.setFixedSize(self.centralWidget.minimumSize())
        # self.centralWidget.setFixedWidth(self.centralWidget.minimumWidth())
        # self.centralWidget.setMaximumWidth(self.centralWidget.minimumWidth())
        self.centralWidget.setFixedWidth(
            self.centralWidget.minimumSizeHint().width())

        dock_display = {}
        for i in range(len(channels)):
            dock_display[channels[i]] = dock.Dock('Image Display ' +
                                                  channels[i],
                                                  autoOrientation=False)
            dock_display[channels[i]].showTitleBar()
            dock_display[channels[i]].addWidget(
                self.imageDisplayWindow[channels[i]].widget)
            dock_display[channels[i]].setStretch(x=100, y=None)
        dock_controlPanel = dock.Dock('Controls', autoOrientation=False)
        # dock_controlPanel.showTitleBar()
        dock_controlPanel.addWidget(self.centralWidget)
        dock_controlPanel.setStretch(x=1, y=None)
        dock_controlPanel.setFixedWidth(
            dock_controlPanel.minimumSizeHint().width())
        main_dockArea = dock.DockArea()
        for i in range(len(channels)):
            if i == 0:
                main_dockArea.addDock(dock_display[channels[i]])
            else:
                main_dockArea.addDock(dock_display[channels[i]], 'right')
        main_dockArea.addDock(dock_controlPanel, 'right')
        self.setCentralWidget(main_dockArea)
        desktopWidget = QDesktopWidget()
        height_min = 0.9 * desktopWidget.height()
        width_min = 0.96 * desktopWidget.width()
        self.setMinimumSize(width_min, height_min)

        # make connections
        for i in range(len(channels)):
            self.streamHandler[channels[i]].signal_new_frame_received.connect(
                self.liveController[channels[i]].on_new_frame)
            self.streamHandler[channels[i]].image_to_display.connect(
                self.imageDisplayWindow[channels[i]].display_image)
            self.streamHandler[channels[i]].packet_image_to_write.connect(
                self.imageSaver[channels[i]].enqueue)
            self.liveControlWidget[channels[i]].signal_newExposureTime.connect(
                self.cameraSettingWidget[channels[i]].set_exposure_time)
            self.liveControlWidget[channels[i]].signal_newAnalogGain.connect(
                self.cameraSettingWidget[channels[i]].set_analog_gain)
            self.liveControlWidget[channels[i]].update_camera_settings()
            self.triggerControlWidget.signal_toggle_live.connect(
                self.liveControlWidget[channels[i]].btn_live.setChecked)
            self.triggerControlWidget.signal_toggle_live.connect(
                self.liveControlWidget[channels[i]].toggle_live)
            self.triggerControlWidget.signal_trigger_mode.connect(
                self.liveControlWidget[channels[i]].set_trigger_mode)
            self.triggerControlWidget.signal_trigger_fps.connect(
                self.liveControlWidget[channels[i]].entry_triggerFPS.setValue)
            self.camera[channels[i]].set_callback(
                self.streamHandler[channels[i]].on_new_frame)
            self.camera[channels[i]].enable_callback()
        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load objects
        self.microcontroller = microcontroller.Microcontroller()
        self.navigationController = core.NavigationController(
            self.microcontroller)

        self.camera_1 = camera.Camera(sn='FW0190110139')  # tracking
        self.camera_2 = camera.Camera(sn='FU0190090030')  # oil

        self.configurationManager_1 = core.ConfigurationManager(
            filename=str(Path.home()) + "/configurations_tracking.xml")
        self.configurationManager_2 = core.ConfigurationManager(
            filename=str(Path.home()) + "/configurations_oil.xml")

        self.streamHandler_1 = core.StreamHandler()
        self.liveController_1 = core.LiveController(
            self.camera_1,
            self.microcontroller,
            self.configurationManager_1,
            control_illumination=False)
        #self.autofocusControlle_1 = core.AutoFocusController(self.camera,self.navigationController,self.liveController)
        #self.multipointController_1 = core.MultiPointController(self.camera,self.navigationController,self.liveController,self.autofocusController,self.configurationManager)
        self.imageSaver_1 = core.ImageSaver()

        self.streamHandler_2 = core.StreamHandler()
        self.liveController_2 = core.LiveController(
            self.camera_2,
            self.microcontroller,
            self.configurationManager_2,
            control_illumination=True)
        self.autofocusController_2 = core.AutoFocusController(
            self.camera_2, self.navigationController, self.liveController_2)
        self.multipointController_2 = core.MultiPointController(
            self.camera_2, self.navigationController, self.liveController_2,
            self.autofocusController_2, self.configurationManager_2)
        self.imageSaver_2 = core.ImageSaver()

        self.trackingController = core.TrackingController(
            self.microcontroller, self.navigationController)

        # open the camera
        # camera start streaming
        self.camera_1.open()
        self.camera_1.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera_1.set_callback(self.streamHandler_1.on_new_frame)
        self.camera_1.enable_callback()

        self.camera_2.open()
        self.camera_2.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera_2.set_callback(self.streamHandler_2.on_new_frame)
        self.camera_2.enable_callback()

        # load widgets
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)

        self.cameraSettingWidget_1 = widgets.CameraSettingsWidget(
            self.camera_1, self.liveController_1)
        self.liveControlWidget_1 = widgets.LiveControlWidget(
            self.streamHandler_1, self.liveController_1,
            self.configurationManager_1)
        self.recordingControlWidget_1 = widgets.RecordingWidget(
            self.streamHandler_1, self.imageSaver_1)
        #self.trackingControlWidget = widgets.TrackingControllerWidget(self.streamHandler_1,self.trackingController)

        self.cameraSettingWidget_2 = widgets.CameraSettingsWidget(
            self.camera_2, self.liveController_2)
        self.liveControlWidget_2 = widgets.LiveControlWidget(
            self.streamHandler_2, self.liveController_2,
            self.configurationManager_2)
        #self.recordingControlWidget_2 = widgets.RecordingWidget(self.streamHandler_2,self.imageSaver_2)
        self.multiPointWidget_2 = widgets.MultiPointWidget(
            self.multipointController_2, self.configurationManager_2)

        # layout widgets
        layout = QGridLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget_1, 0, 0)
        layout.addWidget(self.liveControlWidget_1, 1, 0)
        layout.addWidget(self.navigationWidget, 2, 0)
        #layout.addWidget(self.autofocusWidget,3,0)
        layout.addWidget(self.recordingControlWidget_1, 4, 0)

        layout.addWidget(self.cameraSettingWidget_2, 5, 0)
        layout.addWidget(self.liveControlWidget_2, 6, 0)
        #layout.addWidget(self.recordingControlWidget_2,7,0)
        layout.addWidget(self.multiPointWidget_2, 8, 0)

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        self.setCentralWidget(self.centralWidget)

        # load window
        self.imageDisplayWindow_1 = core.ImageDisplayWindow('Tracking')
        self.imageDisplayWindow_1.show()
        self.imageDisplayWindow_2 = core.ImageDisplayWindow('Oil')
        self.imageDisplayWindow_2.show()
        # self.imageArrayDisplayWindow = core.ImageArrayDisplayWindow('Multi-channel')
        # self.imageArrayDisplayWindow.show()

        # make connections
        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)

        self.streamHandler_1.signal_new_frame_received.connect(
            self.liveController_1.on_new_frame)
        self.streamHandler_1.image_to_display.connect(
            self.imageDisplayWindow_1.display_image)
        self.streamHandler_1.packet_image_to_write.connect(
            self.imageSaver_1.enqueue)
        #self.streamHandler_1.packet_image_for_tracking.connect(self.trackingController.on_new_frame)

        self.liveControlWidget_1.signal_newExposureTime.connect(
            self.cameraSettingWidget_1.set_exposure_time)
        self.liveControlWidget_1.signal_newAnalogGain.connect(
            self.cameraSettingWidget_1.set_analog_gain)
        self.liveControlWidget_1.update_camera_settings()

        self.streamHandler_2.signal_new_frame_received.connect(
            self.liveController_2.on_new_frame)
        self.streamHandler_2.image_to_display.connect(
            self.imageDisplayWindow_2.display_image)
        self.streamHandler_2.packet_image_to_write.connect(
            self.imageSaver_2.enqueue)

        self.liveControlWidget_2.signal_newExposureTime.connect(
            self.cameraSettingWidget_2.set_exposure_time)
        self.liveControlWidget_2.signal_newAnalogGain.connect(
            self.cameraSettingWidget_2.set_analog_gain)
        self.liveControlWidget_2.update_camera_settings()

        self.multipointController_2.image_to_display.connect(
            self.imageDisplayWindow_2.display_image)
        # self.multipointController_2.image_to_display_multi.connect(self.imageArrayDisplayWindow.display_image)
        self.multipointController_2.signal_current_configuration.connect(
            self.liveControlWidget_2.set_microscope_mode)
示例#7
0
    def __init__(self, is_simulation=False, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load window
        if ENABLE_TRACKING:
            self.imageDisplayWindow = core.ImageDisplayWindow(
                draw_crosshairs=True)
            self.imageDisplayWindow.show_ROI_selector()
        else:
            self.imageDisplayWindow = core.ImageDisplayWindow(
                draw_crosshairs=True)
        self.imageArrayDisplayWindow = core.ImageArrayDisplayWindow()
        # self.imageDisplayWindow.show()
        # self.imageArrayDisplayWindow.show()

        # image display windows
        self.imageDisplayTabs = QTabWidget()
        self.imageDisplayTabs.addTab(self.imageDisplayWindow.widget,
                                     "Live View")
        self.imageDisplayTabs.addTab(self.imageArrayDisplayWindow.widget,
                                     "Multichannel Acquisition")

        # load objects
        if is_simulation:
            self.camera = camera.Camera_Simulation(
                rotate_image_angle=ROTATE_IMAGE_ANGLE, flip_image=FLIP_IMAGE)
            self.microcontroller = microcontroller.Microcontroller_Simulation()
        else:
            self.camera = camera.Camera(rotate_image_angle=ROTATE_IMAGE_ANGLE,
                                        flip_image=FLIP_IMAGE)
            self.microcontroller = microcontroller.Microcontroller()

        # configure the actuators
        self.microcontroller.configure_actuators()

        self.configurationManager = core.ConfigurationManager()
        self.streamHandler = core.StreamHandler(
            display_resolution_scaling=DEFAULT_DISPLAY_CROP / 100)
        self.liveController = core.LiveController(self.camera,
                                                  self.microcontroller,
                                                  self.configurationManager)
        self.navigationController = core.NavigationController(
            self.microcontroller)
        self.autofocusController = core.AutoFocusController(
            self.camera, self.navigationController, self.liveController)
        self.multipointController = core.MultiPointController(
            self.camera, self.navigationController, self.liveController,
            self.autofocusController, self.configurationManager)
        if ENABLE_TRACKING:
            self.trackingController = core.TrackingController(
                self.camera, self.microcontroller, self.navigationController,
                self.configurationManager, self.liveController,
                self.autofocusController, self.imageDisplayWindow)
        self.imageSaver = core.ImageSaver(
            image_format=Acquisition.IMAGE_FORMAT)
        self.imageDisplay = core.ImageDisplay()

        # open the camera
        # camera start streaming
        self.camera.open()
        # self.camera.set_reverse_x(CAMERA_REVERSE_X) # these are not implemented for the cameras in use
        # self.camera.set_reverse_y(CAMERA_REVERSE_Y) # these are not implemented for the cameras in use
        self.camera.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera.set_callback(self.streamHandler.on_new_frame)
        self.camera.enable_callback()

        # load widgets
        self.cameraSettingWidget = widgets.CameraSettingsWidget(
            self.camera, include_gain_exposure_time=False)
        self.liveControlWidget = widgets.LiveControlWidget(
            self.streamHandler, self.liveController, self.configurationManager)
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)
        self.dacControlWidget = widgets.DACControWidget(self.microcontroller)
        self.autofocusWidget = widgets.AutoFocusWidget(
            self.autofocusController)
        self.recordingControlWidget = widgets.RecordingWidget(
            self.streamHandler, self.imageSaver)
        if ENABLE_TRACKING:
            self.trackingControlWidget = widgets.TrackingControllerWidget(
                self.trackingController,
                self.configurationManager,
                show_configurations=TRACKING_SHOW_MICROSCOPE_CONFIGURATIONS)
        self.multiPointWidget = widgets.MultiPointWidget(
            self.multipointController, self.configurationManager)

        self.recordTabWidget = QTabWidget()
        if ENABLE_TRACKING:
            self.recordTabWidget.addTab(self.trackingControlWidget, "Tracking")
        self.recordTabWidget.addTab(self.recordingControlWidget,
                                    "Simple Recording")
        self.recordTabWidget.addTab(self.multiPointWidget,
                                    "Multipoint Acquisition")

        # layout widgets
        layout = QVBoxLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget)
        layout.addWidget(self.liveControlWidget)
        layout.addWidget(self.navigationWidget)
        if SHOW_DAC_CONTROL:
            layout.addWidget(self.dacControlWidget)
        layout.addWidget(self.autofocusWidget)
        layout.addWidget(self.recordTabWidget)
        layout.addStretch()

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        # self.centralWidget.setFixedSize(self.centralWidget.minimumSize())
        # self.centralWidget.setFixedWidth(self.centralWidget.minimumWidth())
        # self.centralWidget.setMaximumWidth(self.centralWidget.minimumWidth())
        self.centralWidget.setFixedWidth(
            self.centralWidget.minimumSizeHint().width())

        if SINGLE_WINDOW:
            dock_display = dock.Dock('Image Display', autoOrientation=False)
            dock_display.showTitleBar()
            dock_display.addWidget(self.imageDisplayTabs)
            dock_display.setStretch(x=100, y=None)
            dock_controlPanel = dock.Dock('Controls', autoOrientation=False)
            # dock_controlPanel.showTitleBar()
            dock_controlPanel.addWidget(self.centralWidget)
            dock_controlPanel.setStretch(x=1, y=None)
            dock_controlPanel.setFixedWidth(
                dock_controlPanel.minimumSizeHint().width())
            main_dockArea = dock.DockArea()
            main_dockArea.addDock(dock_display)
            main_dockArea.addDock(dock_controlPanel, 'right')
            self.setCentralWidget(main_dockArea)
            desktopWidget = QDesktopWidget()
            height_min = 0.9 * desktopWidget.height()
            width_min = 0.96 * desktopWidget.width()
            self.setMinimumSize(width_min, height_min)
        else:
            self.setCentralWidget(self.centralWidget)
            self.tabbedImageDisplayWindow = QMainWindow()
            self.tabbedImageDisplayWindow.setCentralWidget(
                self.imageDisplayTabs)
            self.tabbedImageDisplayWindow.setWindowFlags(
                self.windowFlags() | Qt.CustomizeWindowHint)
            self.tabbedImageDisplayWindow.setWindowFlags(
                self.windowFlags() & ~Qt.WindowCloseButtonHint)
            desktopWidget = QDesktopWidget()
            width = 0.96 * desktopWidget.height()
            height = width
            self.tabbedImageDisplayWindow.setFixedSize(width, height)
            self.tabbedImageDisplayWindow.show()

        # make connections
        self.streamHandler.signal_new_frame_received.connect(
            self.liveController.on_new_frame)
        self.streamHandler.image_to_display.connect(self.imageDisplay.enqueue)
        self.streamHandler.packet_image_to_write.connect(
            self.imageSaver.enqueue)
        # self.streamHandler.packet_image_for_tracking.connect(self.trackingController.on_new_frame)
        self.imageDisplay.image_to_display.connect(
            self.imageDisplayWindow.display_image
        )  # may connect streamHandler directly to imageDisplayWindow
        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)
        if ENABLE_TRACKING:
            self.navigationController.signal_joystick_button_pressed.connect(
                self.trackingControlWidget.slot_joystick_button_pressed)
        else:
            self.navigationController.signal_joystick_button_pressed.connect(
                self.autofocusController.autofocus)
        self.autofocusController.image_to_display.connect(
            self.imageDisplayWindow.display_image)
        self.multipointController.image_to_display.connect(
            self.imageDisplayWindow.display_image)
        self.multipointController.signal_current_configuration.connect(
            self.liveControlWidget.set_microscope_mode)
        self.multipointController.image_to_display_multi.connect(
            self.imageArrayDisplayWindow.display_image)
        self.liveControlWidget.signal_newExposureTime.connect(
            self.cameraSettingWidget.set_exposure_time)
        self.liveControlWidget.signal_newAnalogGain.connect(
            self.cameraSettingWidget.set_analog_gain)
        self.liveControlWidget.update_camera_settings()
    def __init__(self, simulation=False, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.setWindowTitle('Gravity Machine v3.0')
        self.imaging_channels = CAMERAS.keys()
        print('Available imaging channels: {}'.format(self.imaging_channels))

        #------------------------------------------------------------------
        # Image Displays
        #------------------------------------------------------------------
        self.imageDisplayWindow = {}
        for key in self.imaging_channels:
            self.imageDisplayWindow[key] = core.ImageDisplayWindow(
                key + ' Display', DrawCrossHairs=True)
            if key == TRACKING:
                self.imageDisplayWindow[key].toggle_ROI_selector(True)
        self.imageDisplayWindow_ThresholdedImage = core.ImageDisplayWindow(
            'Thresholded Image')

        #------------------------------------------------------------------
        # Load objects
        #------------------------------------------------------------------
        self.internal_state = core_tracking.InternalState()

        if simulation is True:
            # Define a camera object for each unique image-stream.
            self.camera = {
                key: camera_Daheng.Camera_Simulation()
                for key in self.imaging_channels
            }
            self.microcontroller = microcontroller.Microcontroller_Simulation()
        else:
            self.camera = {}
            for key in self.imaging_channels:
                if (CAMERAS[key]['make'] == 'TIS'):
                    import control.camera_TIS as camera_TIS
                    self.camera[key] = camera_TIS.Camera(
                        serial=CAMERAS[key]['serial'],
                        width=CAMERAS[key]['px_format'][0],
                        height=CAMERAS[key]['px_format'][1],
                        framerate=CAMERAS[key]['fps'],
                        color=CAMERAS[key]['is_color'])
                elif (CAMERAS[key]['make'] == 'Daheng'):
                    self.camera[key] = camera_Daheng.Camera(
                        sn=CAMERAS[key]['serial'])
                self.camera[key].open()
            self.microcontroller = microcontroller.Microcontroller()

        self.microcontroller.configure_actuators()

        self.streamHandler = {}
        self.imageSaver = {}
        for key in self.imaging_channels:
            # load stream handler
            if 'is_polarization' in CAMERAS[key]:
                if CAMERAS[key]['is_polarization']:
                    is_polarization = True
                else:
                    is_polarization = False
            else:
                is_polarization = False
            self.streamHandler[key] = core.StreamHandler(
                camera=self.camera[key],
                crop_width=CAMERAS[key]['px_format'][0],
                crop_height=CAMERAS[key]['px_format'][1],
                imaging_channel=key,
                rotate_image_angle=CAMERAS[key]['rotate image angle'],
                flip_image=CAMERAS[key]['flip image'],
                is_polarization_camera=is_polarization)
            # load image saver
            self.imageSaver[key] = core_tracking.ImageSaver(
                self.internal_state,
                imaging_channel=key,
                image_format=IMAGE_FORMAT)

        self.liveController = {
            key: core.LiveController(self.camera[key], self.microcontroller)
            for key in self.imaging_channels
        }
        self.navigationController = core.NavigationController(
            self.microcontroller)
        self.stateUpdater = core_tracking.StateUpdater(
            self.navigationController, self.internal_state)
        self.microcontroller.set_callback(
            self.stateUpdater.read_microcontroller)
        self.trackingController = core_tracking.TrackingController(
            self.navigationController, self.microcontroller,
            self.internal_state)
        self.trackingDataSaver = core_tracking.TrackingDataSaver(
            self.internal_state)

        #------------------------------------------------------------------
        # load widgets
        #------------------------------------------------------------------
        self.cameraSettingsWidget = {
            key: widgets.CameraSettingsWidget(self.camera[key],
                                              self.liveController[key])
            for key in self.imaging_channels
        }
        self.liveControlWidget = widgets.LiveControlWidget(
            self.streamHandler[TRACKING], self.liveController,
            self.internal_state)
        self.navigationWidget = widgets_tracking.NavigationWidget(
            self.navigationController, self.internal_state)
        self.trackingControlWidget = widgets_tracking.TrackingControllerWidget(
            self.streamHandler[TRACKING], self.trackingController,
            self.trackingDataSaver, self.internal_state,
            self.imageDisplayWindow[TRACKING], self.microcontroller)
        self.PID_Group_Widget = widgets_tracking.PID_Group_Widget(
            self.trackingController)
        self.recordingControlWidget = widgets.RecordingWidget(
            self.streamHandler, self.imageSaver, self.internal_state,
            self.trackingDataSaver, self.imaging_channels)
        self.plotWidget = widgets.dockAreaPlot(self.internal_state)
        self.ledMatrixControlWidget = widgets.LEDMatrixControlWidget(
            self.microcontroller)

        self.liveSettings_Tab = QTabWidget()
        self.liveSettings_Tab.addTab(self.liveControlWidget, 'Live controller')
        for key in self.imaging_channels:
            self.liveSettings_Tab.addTab(self.cameraSettingsWidget[key], key)

        #------------------------------------------------------------------
        # Connections
        #------------------------------------------------------------------
        # Connections that involve all image streams
        for channel in self.imaging_channels:
            self.streamHandler[channel].signal_new_frame_received.connect(
                self.liveController[channel].on_new_frame)
            self.streamHandler[channel].image_to_display.connect(
                self.imageDisplayWindow[channel].display_image)
            self.streamHandler[channel].packet_image_to_write.connect(
                self.imageSaver[channel].enqueue)
            self.imageSaver[channel].imageName.connect(
                self.trackingDataSaver.setImageName)
            self.streamHandler[channel].signal_fps_save.connect(
                self.recordingControlWidget.update_save_fps)

        # Connections that involve only the tracking image stream
        self.streamHandler[TRACKING].thresh_image_to_display.connect(
            self.imageDisplayWindow_ThresholdedImage.display_image)
        self.streamHandler[TRACKING].packet_image_for_tracking.connect(
            self.trackingController.on_new_frame)
        # @@@ Currently the resolution-scaling only controls the TRACKING stream
        self.streamHandler[TRACKING].signal_working_resolution.connect(
            self.liveControlWidget.update_working_resolution)
        # Only display the image-display rate of the main/tracking image stream
        self.streamHandler[TRACKING].signal_fps_display.connect(
            self.liveControlWidget.update_display_fps)
        # self.trackingController.centroid_image.connect(self.imageDisplayWindow[TRACKING].draw_circle)
        self.trackingController.Rect_pt1_pt2.connect(
            self.imageDisplayWindow[TRACKING].draw_rectangle)
        self.trackingController.save_data_signal.connect(
            self.trackingDataSaver.enqueue)
        self.trackingController.signal_tracking_fps.connect(
            self.liveControlWidget.update_stream_fps)
        self.trackingController.signal_update_plots.connect(
            self.plotWidget.update_plots)

        for channel in self.imaging_channels:
            self.streamHandler[channel].signal_fps.connect(
                self.cameraSettingsWidget[channel].update_stream_fps)
        self.trackingController.get_roi_bbox.connect(
            self.imageDisplayWindow[TRACKING].send_bbox)
        self.imageDisplayWindow[TRACKING].roi_bbox.connect(
            self.trackingController.tracker_image.set_roi_bbox)
        self.trackingControlWidget.show_roi.connect(
            self.imageDisplayWindow[TRACKING].toggle_ROI_selector)
        self.recordingControlWidget.start_tracking_signal.connect(
            self.trackingControlWidget.slot_start_tracking)
        self.stateUpdater.signal_joystick_button_pressed.connect(
            self.trackingControlWidget.slot_joystick_button_pressed)
        self.stateUpdater.signal_stage_tracking_status_changed.connect(
            self.trackingControlWidget.slot_update_stage_tracking_status)
        self.liveControlWidget.signal_update_pixel_size.connect(
            self.trackingController.update_pixel_size)
        self.liveControlWidget._update_pixel_size()
        self.liveControlWidget.signal_update_image_resizing_factor.connect(
            self.trackingController.update_image_resizing_factor)
        self.liveControlWidget._update_image_resizing_factor()

        # tracking start/stop
        self.trackingController.signal_stop_tracking.connect(
            self.trackingControlWidget.slot_stop_tracking)
        self.trackingController.signal_stop_tracking.connect(
            self.streamHandler[TRACKING].stop_tracking)

        #-----------------------------------------------------
        # Dock area for image display
        #-----------------------------------------------------
        self.image_window = QMainWindow()
        image_display_dockArea = dock.DockArea()
        self.image_window.setCentralWidget(image_display_dockArea)
        self.image_window.setWindowTitle('Image display')
        image_window_docks = dict()

        last_channel = None
        for channel in self.imaging_channels:
            image_window_docks[channel] = dock.Dock(channel,
                                                    autoOrientation=False)
            image_window_docks[channel].setTitle(channel)
            image_window_docks[channel].showTitleBar()
            print(image_window_docks[channel].title())
            # image_window_docks[channel].setOrientation(o = 'vertical', force = True)
            # image_window_docks[channel].setStretch(x = 1000, y= 1000)
            image_display_dockArea.addDock(image_window_docks[channel],
                                           'bottom')
            image_window_docks[channel].addWidget(
                self.imageDisplayWindow[channel].widget)
            last_channel = channel

        # Add dock for the thresholded image
        thresholded_image_dock = dock.Dock('Thresholded',
                                           autoOrientation=False)
        image_display_dockArea.addDock(thresholded_image_dock, 'right',
                                       image_window_docks[last_channel])
        thresholded_image_dock.addWidget(
            self.imageDisplayWindow_ThresholdedImage.widget)

        #-----------------------------------------------------------------------------------------------
        # PDAF
        #-----------------------------------------------------------------------------------------------
        if TWO_CAMERA_PDAF:
            import control.core_PDAF as core_PDAF
            self.PDAFController = core_PDAF.PDAFController(
                self.trackingController)
            self.PDAFControllerWidget = widgets_tracking.PDAFControllerWidget(
                self.PDAFController)
            self.imageDisplayWindow['PDAF_image1'] = core.ImageDisplayWindow(
                key + ' Display', DrawCrossHairs=True)
            self.imageDisplayWindow['PDAF_image2'] = core.ImageDisplayWindow(
                key + ' Display', DrawCrossHairs=True)
            # add docked imaged display
            PDAF_image1_dock = dock.Dock('PDAF_image1', autoOrientation=False)
            image_display_dockArea.addDock(PDAF_image1_dock, 'bottom')
            PDAF_image1_dock.addWidget(
                self.imageDisplayWindow['PDAF_image1'].widget)
            PDAF_image2_dock = dock.Dock('PDAF_image2', autoOrientation=False)
            image_display_dockArea.addDock(PDAF_image2_dock, 'right',
                                           PDAF_image1_dock)
            PDAF_image2_dock.addWidget(
                self.imageDisplayWindow['PDAF_image2'].widget)
            # make connections
            self.streamHandler['DF1'].image_to_display.connect(
                self.PDAFController.register_image_from_camera_1)
            self.streamHandler['DF2'].image_to_display.connect(
                self.PDAFController.register_image_from_camera_2)
            self.PDAFController.signal_image1.connect(
                self.imageDisplayWindow['PDAF_image1'].display_image)
            self.PDAFController.signal_image2.connect(
                self.imageDisplayWindow['PDAF_image2'].display_image)

        #-----------------------------------------------------------------------------------------------
        # Volumetric Imaging
        #-----------------------------------------------------------------------------------------------
        import control.trigger_controller as trigger_controller
        import control.optotune_lens as optotune_lens
        if VOLUMETRIC_IMAGING:
            self.liquid_lens = optotune_lens.optotune_lens()
            if USE_SEPARATE_TRIGGER_CONTROLLER:
                if simulation:
                    self.trigger_controller = trigger_controller.TriggerController_Simulation(
                        TRIGGERCONTROLLER_SERIAL_NUMBER)
                else:
                    self.trigger_controller = trigger_controller.TriggerController(
                        TRIGGERCONTROLLER_SERIAL_NUMBER)
            else:
                self.trigger_controller = self.microcontroller
            self.volumetricImagingStreamHandler = core_volumetric_imaging.VolumetricImagingStreamHandler(
                self.trackingController,
                imaging_channel='volumetric imaging',
                rotate_image_angle=CAMERAS['volumetric imaging']
                ['rotate image angle'],
                flip_image=CAMERAS['volumetric imaging']['flip image'])
            self.VolumetricImagingImageSaver = core_volumetric_imaging.VolumetricImagingImageSaver(
                self.internal_state)
            self.volumetricImagingController = core_volumetric_imaging.VolumetricImagingController(
                self.camera['volumetric imaging'], self.trigger_controller,
                self.liquid_lens, self.volumetricImagingStreamHandler,
                self.VolumetricImagingImageSaver, self.internal_state)
            self.volumetricImagingWidget = widgets_volumetric_imaging.VolumetricImagingWidget(
                self.volumetricImagingController)
            self.streamHandler[
                'volumetric imaging'] = self.volumetricImagingStreamHandler
            self.imageSaver['volumetric imaging'].close()
            self.imageSaver[
                'volumetric imaging'] = self.VolumetricImagingImageSaver
            self.focusMeasureDisplayWindow = widgets_volumetric_imaging.FocusMeasureDisplayWindow(
            )
            self.focusMeasureDisplayWindow.show()
            self.imageArrayDisplayWindow = core_volumetric_imaging.ImageArrayDisplayWindow(
            )
            self.imageArrayDisplayWindow.show()
            self.volumetricImagingStreamHandler.packet_image_for_array_display.connect(
                self.imageArrayDisplayWindow.display_image)
            self.volumetricImagingStreamHandler.signal_focus_measure_plot.connect(
                self.focusMeasureDisplayWindow.plotWidget.plot)
            if simulation == False:
                # in simulation mode, do not change camera trigger mode (for now) or no new image would be delivered, as the trigger timer is in the livecontroller
                # to do: add a tigger timer in the simulation camera object for simulating hardware trigger
                self.volumetricImagingController.signal_trigger_mode.connect(
                    self.cameraSettingsWidget['volumetric imaging'].
                    set_trigger_mode)
            self.volumetricImagingStreamHandler.signal_defocus.connect(
                self.volumetricImagingWidget.display_defocus.display)
            self.streamHandler[
                'volumetric imaging'].signal_new_frame_received.connect(
                    self.liveController[channel].on_new_frame)
            self.streamHandler['volumetric imaging'].image_to_display.connect(
                self.imageDisplayWindow[channel].display_image)
            self.streamHandler[
                'volumetric imaging'].packet_image_to_write.connect(
                    self.imageSaver[channel].enqueue)
            self.imageSaver['volumetric imaging'].imageName.connect(
                self.trackingDataSaver.setImageName)
            self.streamHandler['volumetric imaging'].signal_fps_save.connect(
                self.recordingControlWidget.update_save_fps)

        #-----------------------------------------------------
        # Layout widgets
        #-----------------------------------------------------
        self.SettingsTab = QTabWidget()
        # self.SettingsTab.addTab(self.PID_Group_Widget, 'PID')
        if TWO_CAMERA_PDAF:
            self.SettingsTab.addTab(self.PDAFControllerWidget, 'PDAF')
        if VOLUMETRIC_IMAGING:
            self.SettingsTab.addTab(self.volumetricImagingWidget,
                                    'Volumetric Imaging')
        self.SettingsTab.addTab(self.navigationWidget, 'Stage Control')
        self.SettingsTab.addTab(self.ledMatrixControlWidget, 'LED Matrix')
        self.SettingsTab.addTab(self.plotWidget, 'Plots')

        layout_left = QVBoxLayout()
        layout_left.addWidget(self.liveSettings_Tab)
        layout_left.addWidget(self.trackingControlWidget)
        layout_left.addWidget(self.recordingControlWidget)
        layout_left.addStretch()

        layout_right = QVBoxLayout()
        layout_right.addWidget(self.SettingsTab)
        layout_right.addWidget(self.PID_Group_Widget)

        overall_layout = QHBoxLayout()
        overall_layout.addLayout(layout_left)
        overall_layout.addLayout(layout_right)

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(overall_layout)
        self.setCentralWidget(self.centralWidget)

        #-----------------------------------------------------
        # Start all image-streams
        #-----------------------------------------------------
        for channel in self.imaging_channels:
            self.camera[channel].set_software_triggered_acquisition(
            )  #self.camera.set_continuous_acquisition()
            self.camera[channel].set_callback(
                self.streamHandler[channel].on_new_frame)
            self.camera[channel].enable_callback()
            self.camera[channel].start_streaming()
        self.image_window.show()
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load objects
        self.camera_1 = camera.Camera(sn='FW0190110139')
        self.camera_2 = camera.Camera(sn='FU0190090030')
        self.microcontroller = microcontroller.Microcontroller()

        self.streamHandler_1 = core.StreamHandler()
        self.streamHandler_2 = core.StreamHandler()
        self.liveController_1 = core.LiveController(self.camera_1,
                                                    self.microcontroller)
        self.liveController_2 = core.LiveController(self.camera_2,
                                                    self.microcontroller)
        self.navigationController = core.NavigationController(
            self.microcontroller)
        self.autofocusController = core.AutoFocusController(
            self.camera_1, self.navigationController, self.liveController_1)
        self.trackingController = core.TrackingController(
            self.microcontroller, self.navigationController)
        self.imageSaver_1 = core.ImageSaver()
        self.imageSaver_2 = core.ImageSaver()
        self.imageDisplay_1 = core.ImageDisplay()
        self.imageDisplay_2 = core.ImageDisplay()
        '''
		# thread
		self.thread_multiPoint = QThread()
		self.thread_multiPoint.start()
		self.multipointController.moveToThread(self.thread_multiPoint)
		'''

        # open the camera
        # camera start streaming
        self.camera_1.open()
        self.camera_1.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera_1.set_callback(self.streamHandler_1.on_new_frame)
        self.camera_1.enable_callback()

        self.camera_2.open()
        self.camera_2.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera_2.set_callback(self.streamHandler_2.on_new_frame)
        self.camera_2.enable_callback()

        # load widgets
        self.cameraSettingWidget_1 = widgets.CameraSettingsWidget(
            self.camera_1, self.liveController_1)
        self.liveControlWidget_1 = widgets.LiveControlWidget(
            self.streamHandler_1, self.liveController_1)
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)
        self.autofocusWidget = widgets.AutoFocusWidget(
            self.autofocusController)
        self.recordingControlWidget_1 = widgets.RecordingWidget(
            self.streamHandler_1, self.imageSaver_1)
        self.trackingControlWidget = widgets.TrackingControllerWidget(
            self.streamHandler_1, self.trackingController)

        self.cameraSettingWidget_2 = widgets.CameraSettingsWidget(
            self.camera_2, self.liveController_2)
        self.liveControlWidget_2 = widgets.LiveControlWidget(
            self.streamHandler_2, self.liveController_2)
        self.recordingControlWidget_2 = widgets.RecordingWidget(
            self.streamHandler_2, self.imageSaver_2)

        # layout widgets
        layout = QGridLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget_1, 0, 0)
        layout.addWidget(self.liveControlWidget_1, 1, 0)
        layout.addWidget(self.navigationWidget, 2, 0)
        layout.addWidget(self.autofocusWidget, 3, 0)
        layout.addWidget(self.recordingControlWidget_1, 4, 0)

        layout.addWidget(self.cameraSettingWidget_2, 5, 0)
        layout.addWidget(self.liveControlWidget_2, 6, 0)
        layout.addWidget(self.recordingControlWidget_2, 7, 0)

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        self.setCentralWidget(self.centralWidget)

        # load window
        self.imageDisplayWindow_1 = core.ImageDisplayWindow()
        self.imageDisplayWindow_1.show()
        self.imageDisplayWindow_2 = core.ImageDisplayWindow()
        self.imageDisplayWindow_2.show()

        # make connections
        self.streamHandler_1.signal_new_frame_received.connect(
            self.liveController_1.on_new_frame)
        self.streamHandler_1.image_to_display.connect(
            self.imageDisplay_1.enqueue)
        self.streamHandler_1.packet_image_to_write.connect(
            self.imageSaver_1.enqueue)
        self.streamHandler_1.packet_image_for_tracking.connect(
            self.trackingController.on_new_frame)
        self.imageDisplay_1.image_to_display.connect(
            self.imageDisplayWindow_1.display_image
        )  # may connect streamHandler directly to imageDisplayWindow

        self.streamHandler_2.signal_new_frame_received.connect(
            self.liveController_2.on_new_frame)
        self.streamHandler_2.image_to_display.connect(
            self.imageDisplay_2.enqueue)
        self.streamHandler_2.packet_image_to_write.connect(
            self.imageSaver_2.enqueue)
        self.imageDisplay_2.image_to_display.connect(
            self.imageDisplayWindow_2.display_image
        )  # may connect streamHandler directly to imageDisplayWindow

        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)
        self.autofocusController.image_to_display.connect(
            self.imageDisplayWindow_1.display_image)

        self.camera_1.start_streaming()
        self.camera_2.start_streaming()