Esempio n. 1
0
    def __init__(self):
        super(FSScanProcessor, self).__init__()

        self.eventManager = FSEventManager.instance()
        self.settings = Settings.instance()
        self.config = Config.instance()

        self._logger = logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)

        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 +
                                                  1)
        self.current_position = 0
        self._laser_angle = 33.0
        self._stop_scan = False
        self._current_laser_position = 1

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

        self._worker_pool = FSImageWorkerPool(self.image_task_q, self.event_q)
        self.hardwareController = HardwareController.instance()
        self.eventManager.subscribe(FSEvents.ON_IMAGE_PROCESSED,
                                    self.image_processed)
        self._scan_brightness = self.settings.camera.brightness
        self._scan_contrast = self.settings.camera.contrast
        self._scan_saturation = self.settings.camera.saturation
    def __init__(self):
        super(FSScanProcessor, self).__init__()
        self._logger =  logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)
        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(5)
        self.current_position = 0
        self._laser_angle = 33.0
        self._stop_scan = False
        self._current_laser_position = 1
        self.eventManager = FSEventManager.instance()
        self.settings = Settings.instance()
        self.config = Config.instance()
        self.semaphore = multiprocessing.BoundedSemaphore()
        self._contrast = 0.5
        self._brightness = 0.5


        self.event_q = self.eventManager.get_event_q()

        self._worker_pool = FSImageWorkerPool(self.image_task_q,self.event_q)
        self.hardwareController = HardwareController.instance()
        self.eventManager.subscribe(FSEvents.ON_IMAGE_PROCESSED, self.image_processed)
        self._scan_brightness = self.settings.camera.brightness
        self._scan_contrast =  self.settings.camera.contrast
 def __init__(self):
     super(FSSettingsPreviewProcessor, self).__init__()
     self.hardwareController = HardwareController.instance()
     self.eventManager = FSEventManager.instance()
     self.config = Config.instance()
     self.settings = Settings.instance()
     self._image_processor = ImageProcessor(self.config, self.settings)
Esempio n. 4
0
    def run(self):
        self._logger.info("FabScanPi-Server "+str(__version__))

        try:

            # create Singleton instances
            _config = Config.instance(self.config_file)
            _settings = Settings.instance(self.settings_file)

            _hardwareController = HardwareController.instance()
            _eventManager = FSEventManager.instance()

            # Websocket Server
            self.fsWebSocketServer = FSWebSocketServer()
            self.fsWebSocketServer.start()

            _scanner = FSScanner()
            _scanner.start()

            # Web Server
            self.fsWebServer = WebServer()
            self.fsWebServer.serve_forever()

        except (KeyboardInterrupt, SystemExit):

            time.sleep(0.5)
            _hardwareController.laser.off()
            _hardwareController.led.off()
            _hardwareController.turntable.stop_turning()

            sys.exit(0)
Esempio n. 5
0
    def __init__(self, cambuffer):
        threading.Thread.__init__(self)

        self._logger =  logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)

        self.config = Config.instance()
        self.camera_buffer = cambuffer
        self.isRecording = True
        self.timestamp = int(round(time.time() * 1000))
        self.semaphore = threading.BoundedSemaphore()
        self.config = Config.instance()
        self.settings = Settings.instance()

        self.prior_image = None
        self.stream = None

        # auto exposure mode for logitech C270 can not be controlled by opencv, with this work
        # around the exposer mode can be set direcly by v4l2
        subprocess.call(["v4l2-ctl", "--set-ctrl", "exposure_auto=1"])

        self.camera = cv2.VideoCapture(self.config.camera.device)

        self.camera.set(3,1280)
        self.camera.set(4,720)
        self._logger.debug("Selected Camera Device %i" % (int(self.config.camera.device)))
        self.start()
Esempio n. 6
0
    def __init__(self, cambuffer):
        threading.Thread.__init__(self)

        self._logger =  logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)

        self.config = Config.instance()
        self.camera_buffer = cambuffer
        self.isRecording = True
        self.timestamp = int(round(time.time() * 1000))
        self.semaphore = threading.BoundedSemaphore()
        self.config = Config.instance()
        self.settings = Settings.instance()

        self.prior_image = None
        self.stream = None

        # auto exposure mode for logitech C270 can not be controlled by opencv, with this work
        # around the exposer mode can be set direcly by v4l2
        # a value of 1 deactivates auto exposure
        #subprocess.call(["v4l2-ctl", "--set-ctrl", "exposure_auto=1"])

        try:
            self.camera = cv2.VideoCapture(self.config.camera.device)
        except:
            self._logger.error("Can not create camera device.")
            return

        # this sets the resolution of the C270 which is 1280x720 by default
        self.camera.set(3,1280)
        self.camera.set(4,720)
        self._logger.debug("Selected Camera Device %i" % (int(self.config.camera.device)))
        self.start()
Esempio n. 7
0
 def __init__(self):
     super(FSSettingsPreviewProcessor, self).__init__()
     self.hardwareController = HardwareController.instance()
     self.eventManager = FSEventManager.instance()
     self.config = Config.instance()
     self.settings = Settings.instance()
     self._image_processor = ImageProcessor(self.config, self.settings)
Esempio n. 8
0
    def __init__(self, cambuffer):
        threading.Thread.__init__(self)

        self._logger = logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)

        self.config = Config.instance()
        self.camera_buffer = cambuffer
        self.isRecording = True
        self.timestamp = int(round(time.time() * 1000))
        self.semaphore = threading.BoundedSemaphore()
        self.config = Config.instance()
        self.settings = Settings.instance()

        self.prior_image = None
        self.stream = None

        # auto exposure mode for logitech C270 can not be controlled by opencv, with this work
        # around the exposer mode can be set direcly by v4l2
        # a value of 1 deactivates auto exposure
        #subprocess.call(["v4l2-ctl", "--set-ctrl", "exposure_auto=1"])

        try:
            self.camera = cv2.VideoCapture(self.config.camera.device)
        except:
            self._logger.error("Can not create camera device.")
            return

        # this sets the resolution of the C270 which is 1280x720 by default
        self.camera.set(3, 1280)
        self.camera.set(4, 720)
        self._logger.debug("Selected Camera Device %i" %
                           (int(self.config.camera.device)))
        self.start()
Esempio n. 9
0
 def __init__(self, prefix):
     threading.Thread.__init__(self)
     self.eventManager = FSEventManager.instance()
     self._logger =  logging.getLogger(__name__)
     self._logger.setLevel(logging.DEBUG)
     self.settings = Settings.instance()
     self.config = Config.instance()
     self.prefix = prefix
Esempio n. 10
0
 def __init__(self, id, filter, format):
     threading.Thread.__init__(self)
     self.eventManager = FSEventManager.instance()
     self._logger =  logging.getLogger(__name__)
     self._logger.setLevel(logging.DEBUG)
     self.settings = Settings.instance()
     self.config = Config.instance()
     self.scan_id = id
     self.filter = filter
     self.format = format
Esempio n. 11
0
 def __init__(self, id, filter, format):
     threading.Thread.__init__(self)
     self.eventManager = FSEventManager.instance()
     self._logger = logging.getLogger(__name__)
     self._logger.setLevel(logging.DEBUG)
     self.settings = Settings.instance()
     self.config = Config.instance()
     self.scan_id = id
     self.filter = filter
     self.format = format
Esempio n. 12
0
    def run(self):
        self._logger.info("FabScanPi-Server " + str(__version__))

        try:
            # inject "static" classed
            injector.provide(FSEventManagerInterface, FSEventManagerSingleton)
            injector.provide_instance(FSWebSocketServerInterface,
                                      FSWebSocketServer())
            injector.provide_instance(ConfigInterface,
                                      Config(self.config_file, True))

            injector.provide_instance(SettingsInterface,
                                      Settings(self.settings_file, True))

            # inject "dynamic" classes
            self.config = injector.get_instance(ConfigInterface)
            FSScannerFactory.injectScannerType(self.config.scanner_type)

            # start server services
            websocket_server = injector.get_instance(
                FSWebSocketServerInterface)
            websocket_server.start()

            webserver = FSWebServer()
            webserver.start()

            FSScanner().start()

            FSEventManagerSingleton().instance.subscribe(
                FSEvents.COMMAND, self.on_server_command)

            while not self.exit:
                try:
                    time.sleep(0.3)

                except KeyboardInterrupt:
                    raise

            if self.upgrade:
                self._logger.info("Upgrading FabScanPi Server")
                self.update_server()
                self.restart = True

            if self.restart:
                self._logger.info("Restarting FabScanPi Server")
                self.restart_server()
                self.exit = True

            self._logger.info("FabScan Server Exit. Bye!")
            os._exit(1)

        except (KeyboardInterrupt, SystemExit):
            sys.exit(0)
Esempio n. 13
0
    def __init__(self):

        threading.Thread.__init__(self)
        self._state = FSState.IDLE
        self._logger =  logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)
        self.settings = Settings.instance()
        self.daemon = True
        self.hardwareController = HardwareController.instance()
        self._exit_requested = False

        self.eventManager = FSEventManager.instance()
        self.eventManager.subscribe(FSEvents.ON_CLIENT_CONNECTED, self._on_client_connected)
        self.eventManager.subscribe(FSEvents.COMMAND, self._on_command)
Esempio n. 14
0
    def __init__(self, cambuffer):
        threading.Thread.__init__(self)
        self.start()
        self.isRecording = True
        self.timestamp = int(round(time.time() * 1000))
        self.semaphore = threading.BoundedSemaphore()
        self.camera = None
        self.prior_image = None
        self.stream = None
        self.config = Config.instance()
        self.settings = Settings.instance()
        self.camera_buffer = cambuffer
        self.awb_default_gain = 0

        self._logger =  logging.getLogger(__name__)
Esempio n. 15
0
    def __init__(self):
        threading.Thread.__init__(self)
        self._state = FSState.IDLE
        self._logger = logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)
        self.settings = Settings.instance()
        self.daemon = True
        self.hardwareController = HardwareController.instance()
        self._exit_requested = False
        self.meshingTaskRunning = False

        self._logger.debug("Number of cpu cores: "+str( multiprocessing.cpu_count()))
        self.eventManager = FSEventManager.instance()
        self.eventManager.subscribe(FSEvents.ON_CLIENT_CONNECTED, self._on_client_connected)
        self.eventManager.subscribe(FSEvents.COMMAND, self._on_command)
Esempio n. 16
0
    def __init__(self):
        threading.Thread.__init__(self)
        self._state = FSState.IDLE
        self._logger = logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)
        self.settings = Settings.instance()
        self.daemon = True
        self.hardwareController = HardwareController.instance()
        self._exit_requested = False
        self.meshingTaskRunning = False

        self._logger.debug("Number of cpu cores: "+str( multiprocessing.cpu_count()))
        self.eventManager = FSEventManager.instance()
        self.eventManager.subscribe(FSEvents.ON_CLIENT_CONNECTED, self._on_client_connected)
        self.eventManager.subscribe(FSEvents.COMMAND, self._on_command)
Esempio n. 17
0
    def create(self, number_of_workers):
        '''
            Create Processes in Pool
        '''

        self.set_number_of_workers(number_of_workers)

        for _ in range(self._number_of_workers):
            worker = FSImageWorkerProcess(Settings.instance(), Config.instance(), self._task_q, self._event_q)
            worker.daemon = True
            worker.start()
            self.workers.append(worker)

        self._workers_active = True

        return self.workers
Esempio n. 18
0
    def __init__(self, cambuffer):
        threading.Thread.__init__(self)
        self.start()
        self.isRecording = True
        self.timestamp = int(round(time.time() * 1000))
        self.semaphore = threading.BoundedSemaphore()
        self.camera = None
        self.prior_image = None
        self.stream = None
        self.config = Config.instance()
        self.settings = Settings.instance()
        self.camera_buffer = cambuffer
        self.awb_default_gain = 0
        self.is_idle = True

        self._logger = logging.getLogger(__name__)
Esempio n. 19
0
    def __init__(self):
        self.config = Config.instance()
        self.settings = Settings.instance()

        self.camera = None
        self._image_processor = ImageProcessor(self.config, self.settings)
        self.camera = FSCamera()
        self.serial_connection = FSSerialCom()

        self.turntable = Turntable(self.serial_connection)

        self.laser = Laser(self.serial_connection)
        self.led = Led(self.serial_connection)

        self.laser.off()
        self.led.off()
        self.turntable.stop_turning()
Esempio n. 20
0
    def __init__(self):
        self.config = Config.instance()
        self.settings = Settings.instance()

        self.camera = None
        self._image_processor = ImageProcessor(self.config, self.settings)
        self.camera = FSCamera()
        self.serial_connection = FSSerialCom()

        self.turntable = Turntable(self.serial_connection)

        self.laser = Laser(self.serial_connection)
        self.led = Led(self.serial_connection)

        self.laser.off()
        self.led.off()
        self.turntable.stop_turning()
        self.turntable.disable_motors()
Esempio n. 21
0
    def create_services(self):

        injector.provide(FSEventManagerInterface, FSEventManagerSingleton)
        injector.provide_instance(ConfigInterface, Config(self.config_file))
        injector.provide_instance(SettingsInterface,
                                  Settings(self.settings_file))

        # inject "dynamic" classes
        self.config = injector.get_instance(ConfigInterface)
        FSScannerFactory.injectScannerType(self.config.file.scanner_type)

        self.webserver = FSWebServer()
        self.webserver.start()

        self.scanner = FSScanner()
        self.scanner.start()
        self.eventManager = FSEventManagerSingleton()
        self.eventManager.instance.subscribe(FSEvents.COMMAND,
                                             self.on_server_command)
Esempio n. 22
0
    def create(self, number_of_workers):
        '''
            Create Processes in Pool
        '''

        self.set_number_of_workers(number_of_workers)
        self._logger.info("Creating %i image worker processes." %
                          number_of_workers)

        for _ in range(self._number_of_workers):
            worker = FSImageWorkerProcess(Settings.instance(),
                                          Config.instance(), self._task_q,
                                          self._event_q)
            worker.daemon = True
            worker.start()
            self.workers.append(worker)

        self._workers_active = True

        return self.workers