示例#1
0
    def start(self):
        #self._hardwarecontroller.stop_camera_stream()
        tools = FSSystem()
        tools.delete_folder(self.config.folders.scans + 'calibration')
        self._hardwarecontroller.turntable.enable_motors()
        self._hardwarecontroller.led.on(self.calibration_brightness[0],
                                        self.calibration_brightness[1],
                                        self.calibration_brightness[2])
        #self.settings.camera.contrast = 30
        #self.settings.camera.saturation = 20
        #self.settings.camera.brightness = 50
        self.reset_calibration_values()
        self.settings.threshold = 30
        self._starttime = self.get_time_stamp()

        message = {"message": "START_CALIBRATION", "level": "info"}
        self._eventmanager.broadcast_client_message(FSEvents.ON_INFO_MESSAGE,
                                                    message)

        try:

            self._hardwarecontroller.start_camera_stream(mode="calibration")

            self._do_calibration(self._capture_camera_calibration,
                                 self._calculate_camera_calibration)
            self._do_calibration(self._capture_scanner_calibration,
                                 self._calculate_scanner_calibration)

            if self._stop:
                self._logger.debug("Calibration canceled...")

                # send information to client that calibration is finished
                message = {"message": "STOPPED_CALIBRATION", "level": "info"}
                self._eventmanager.broadcast_client_message(
                    FSEvents.ON_INFO_MESSAGE, message)
                self._stop = False
            else:

                event = FSEvent()
                event.command = 'CALIBRATION_COMPLETE'
                self._eventmanager.publish(FSEvents.COMMAND, event)

                # send information to client that calibration is finished
                message = {"message": "FINISHED_CALIBRATION", "level": "info"}
                self.config.save()

                self._eventmanager.broadcast_client_message(
                    FSEvents.ON_INFO_MESSAGE, message)

            self._hardwarecontroller.stop_camera_stream()

            self._hardwarecontroller.led.off()
            self._hardwarecontroller.turntable.disable_motors()

            self.reset_calibration_values()
            return
        except StandardError as e:
            self._logger.error(e)
    def __init__(self, config, settings, eventmanager, imageprocessor,
                 hardwarecontroller, calibration):
        super(FSScanProcessorInterface,
              self).__init__(self, config, settings, eventmanager,
                             imageprocessor, hardwarecontroller, calibration)

        #asyncio.set_event_loop(asyncio.new_event_loop())
        self.settings = settings
        self.config = config
        self._logger = logging.getLogger(__name__)

        self.eventmanager = eventmanager.instance
        self.calibration = calibration
        self._worker_pool = None
        self.hardwareController = hardwarecontroller
        self.image_processor = imageprocessor

        self._prefix = None
        self._resolution = 16
        self._number_of_pictures = 0
        self._total = 1
        self._progress = 1
        self._is_color_scan = True
        self.point_clouds = []
        self.both_cloud = []

        self.current_position = 0
        self._stop_scan = False
        self._current_laser_position = 1
        self._starttime = 0
        self._additional_worker_number = 1

        self.texture_lock_event = threading.Event()
        self.texture_lock_event.set()

        self.utils = FSSystem()

        self._scan_brightness = self.settings.file.camera.brightness
        self._scan_contrast = self.settings.file.camera.contrast
        self._scan_saturation = self.settings.file.camera.saturation
        self._logger.info("Laser Scan Processor initilized.")

        # prevent deadlocks when opencv tbb is not available

        cv_build_info = cv2.getBuildInformation()

        # fallback to one worker.
        if not "TBB" in cv_build_info:
            self._logger.warning(
                "OpenCV does not support TBB. Falling back to single processing."
            )
            self.config.file.process_numbers = 1
示例#3
0
    def __init__(self, config, settings, eventmanager, imageprocessor,
                 hardwarecontroller, calibration):
        super(FSScanProcessorInterface,
              self).__init__(self, config, settings, eventmanager,
                             imageprocessor, hardwarecontroller, calibration)

        self.settings = settings
        self.config = config
        self._logger = logging.getLogger(__name__)

        self.eventmanager = eventmanager.instance
        self.calibration = calibration

        self.hardwareController = hardwarecontroller
        self.image_processor = imageprocessor

        self._prefix = None
        self._resolution = 16
        self._number_of_pictures = 0
        self._total = 0
        self._laser_positions = 1
        self._progress = 0
        self._is_color_scan = True
        self.point_cloud = None
        self.image_task_q = multiprocessing.Queue(self.config.process_numbers *
                                                  2)
        self.current_position = 0
        self._stop_scan = False
        self._current_laser_position = 1
        self._starttime = 0

        self.utils = FSSystem()

        self.semaphore = multiprocessing.BoundedSemaphore()
        self.event_q = self.eventmanager.get_event_q()

        self._worker_pool = None

        self._scan_brightness = self.settings.camera.brightness
        self._scan_contrast = self.settings.camera.contrast
        self._scan_saturation = self.settings.camera.saturation

        self.eventmanager.subscribe(FSEvents.ON_IMAGE_PROCESSED,
                                    self.image_processed)

        self._logger.info("Laser Scan Processor initilized..." + str(self))
示例#4
0
    def start(self):
        #self._hardwarecontroller.stop_camera_stream()
        tools = FSSystem()
        #self._hardwarecontroller.stop_camera_stream()
        tools.delete_folder(self.config.file.folders.scans + 'calibration')
        self._hardwarecontroller.turntable.enable_motors()
        time.sleep(0.2)

        if self.config.file.laser.interleaved == "False":
            self._logger.debug("Turning Leds on in non interleaved mode.")
            self._hardwarecontroller.led.on(self.calibration_brightness[0],
                                            self.calibration_brightness[1],
                                            self.calibration_brightness[2])

        self.reset_calibration_values()
        self.settings.threshold = 25
        self._starttime = self.get_time_stamp()

        message = {"message": "START_CALIBRATION", "level": "info"}
        self._eventmanager.broadcast_client_message(FSEvents.ON_INFO_MESSAGE,
                                                    message)

        try:

            self._hardwarecontroller.start_camera_stream(mode="calibration")

            self._do_calibration(self._capture_camera_calibration,
                                 self._calculate_camera_calibration)
            self._do_calibration(self._capture_scanner_calibration,
                                 self._calculate_scanner_calibration)

            if self.config.file.laser.interleaved == "False":
                self._hardwarecontroller.led.off()

            self._hardwarecontroller.turntable.disable_motors()

            if self._stop:
                self._logger.debug("Calibration canceled...")

                # send information to client that calibration is finished
                message = {"message": "STOPPED_CALIBRATION", "level": "info"}
                self._eventmanager.broadcast_client_message(
                    FSEvents.ON_INFO_MESSAGE, message)
                self._stop = False
            else:

                event = FSEvent()
                event.command = 'CALIBRATION_COMPLETE'
                self._eventmanager.publish(FSEvents.COMMAND, event)

                # send information to client that calibration is finished
                message = {"message": "FINISHED_CALIBRATION", "level": "info"}
                self.config.save_json()

                self._eventmanager.broadcast_client_message(
                    FSEvents.ON_INFO_MESSAGE, message)

            self._hardwarecontroller.stop_camera_stream()

            self._hardwarecontroller.led.off()
            self._hardwarecontroller.turntable.disable_motors()

            self.reset_calibration_values()
            return
        except Exception as e:
            self._logger.exception(e)
            message = {
                "message": "SCANNER_CALIBRATION_FAILED",
                "level": "warn"
            }

            self._eventmanager.broadcast_client_message(
                FSEvents.ON_INFO_MESSAGE, message)