if __name__ == "__main__": os.system("chcp 65001") parser = optparse.OptionParser() parser.add_option('-p', '--port', type="int", default=19952, dest="port") parser.add_option('-w', '--workers', type="int", default=50, dest="workers") opt, args = parser.parse_args() server_port = opt.port request_limit = system_config.request_limit workers = opt.workers logger = system_config.logger tornado.log.enable_pretty_logging(logger=logger) interface_manager = InterfaceManager() threading.Thread(target=lambda: event_loop(system_config, model_path, interface_manager)).start() sign.set_auth([{ 'accessKey': system_config.access_key, 'secretKey': system_config.secret_key }]) server_host = "0.0.0.0" logger.info('Running on http://{}:{}/ <Press CTRL + C to quit>'.format( server_host, server_port)) app = make_app(system_config.route_map) http_server = tornado.httpserver.HTTPServer(app) http_server.bind(server_port, server_host) http_server.start(1)
def main(): """ Run PurBeurre application """ try: pb_db = Database('PurBeurre_db') # The user can choose to run only the PurBeurre application (> purbeurre_app.py) or # to update the PurBeurre Database before to run the application (> purbeurre_app.py -uDB) parser = argparse.ArgumentParser() parser.add_argument("-uDB", "--updateDB", help="Update database with Data from API", action="store_true") args = parser.parse_args() if args.updateDB: # Create or Update the Database print("\n*** Création ou Mise à jour de la base de données ***\n ") pb_db.call_api() pb_db.create_database() pb_db.create_table() pb_db.insert_category() pb_db.insert_product() else: pass pb_menu = InterfaceManager(pb_db) pb_menu.welcome() while pb_menu.option in [0, 1, 2, 3]: if pb_menu.option == 0: # Option 0 : Access to the main menu pb_menu.display_menu() if pb_menu.option == 1: # Option 1: Allow to research a substitute # by choosing a random product in a random category print("\n ***** Sélectionnez une catégorie :\n ") pb_menu.random_category() print() pb_menu.verif_input1() print("\n ***** Sélectionnez un aliment :\n ") pb_menu.random_product(pb_menu.enter_1) print() pb_menu.verif_input2() print(STARS_LINE2) pb_menu.display_chosen_product() print(STARS_LINE2) pb_menu.display_substitute() pb_menu.display_ask_save() pb_menu.display_all_options() print(STARS_LINE2) if pb_menu.option == 2: # Option 2: Access to the favorite table print(STARS_LINE2) pb_menu.display_favorite() pb_menu.display_options() print(STARS_LINE2) if pb_menu.option == 3: # Option3: Quit the PurBeurre application pb_menu.goodbye() except KeyboardInterrupt: pb_menu.goodbye() finally: # Close the database cursor and connection if pb_db.cursor: pb_db.cursor.close() pb_db.cnx.close()
modes = [ "Off", "Depth recoloring", "Normal recoloring", "Depth-colored rotating light", "Normal-colored orbiting soft light", "Orbiting hard light", "Orbiting soft light", "Orbiting soft light pair", "Orbiting soft light with color variation", "Moving light", "soft face lights", "highlight face" ] interface = InterfaceManager(modes=modes) # Subsample on depth image size sN = 4 realsense_manager = RealsenseHandler( resolution=(640, 480), framerate=30, decimation_magnitude=sN, spatial_smooth=False ) face_mesh_detector = mp_face_mesh.FaceMesh( min_detection_confidence=0.3, min_tracking_confidence=0.2) k = 0 last_time = time.time()
def __init__(self): self.__display_manager = DisplayManager(self) self.thread_manager = ThreadManager() self.interface_manager = InterfaceManager() logging.info('All managers initialised.')