def start_sub(args): """Function that starts the tracking system with the sub jobs according to command-line arguments. Args: args: Command-line arguments. """ if args["sub_jobs"] == "id": if args["id_sub_jobs"] == "set": t_system.identifier.change_keys(args["public_id"], args["private_id"], args["name"]) elif args["id_sub_jobs"] == "show": t_system.identifier.show_keys() elif args["sub_jobs"] == "remote-ui-authentication": t_system.administrator.change_keys(args["ssid"], args["password"]) elif args["sub_jobs"] == "face-encoding": from t_system.face_encoding import FaceEncodeManager face_encode_manager = FaceEncodeManager(args["detection_method"]) face_encode_manager.add_face(args["owner_name"], args["dataset"]) elif args["sub_jobs"] == "self-update": t_system.update_manager.set_editability(args["editable"]) t_system.update_manager.set_verbosity(args["verbose"]) t_system.update_manager.update()
def delete_face(admin_id, face_id): """The high-level method to remove existing face with given id. Args: admin_id (str): Root privileges flag. face_id (str): The id of the position. """ face_encode_manager = FaceEncodeManager() result = face_encode_manager.delete_face(face_id) return result
def update_face(admin_id, face_id, data): """The high-level method to update the face and its encodings that is recorded in database with given parameters. Args: admin_id (str): Root privileges flag. face_id (str): The id of the position. data (dict): Position data structure. """ face_encode_manager = FaceEncodeManager() result = face_encode_manager.update_face(face_id, data["photos"]) return result
def get_face(admin_id, face_id): """The high-level method to return existing face and copying its images under the static folder with given id. Args: admin_id (str): Root privileges flag. face_id (str): The id of the position. """ try: table = get_db_table(is_admin(admin_id)) face = table.search((Query().id == face_id)) if not face: result = [] else: # result = [b.to_dict() for b in record] face_encode_manager = FaceEncodeManager() for face in face_encode_manager.faces: if face.id == face_id: face.copy_images_to( f'{T_SYSTEM_PATH}/remote_ui/www/static/images/face_encodings' ) result = [face[0]] except Exception as e: print(e) result = [] return result
def create_face(admin_id, data): """The high-level method to create new face with its encoding pickle data. Args: admin_id (str): Root privileges flag. data (dict): Position data structure. """ # table = get_db_table(admin_id) face_encode_manager = FaceEncodeManager() face_encode_manager.add_face(data['face_name'], data['photos']) result = True return result
def start_sub(args): """Function that starts the tracking system with the sub jobs according to command-line arguments. Args: args: Command-line arguments. """ if args["sub_jobs"] == "remote-ui-authentication": administrator.change_keys(args["ssid"], args["password"]) elif args["sub_jobs"] == "face-encoding": from t_system.face_encoding import FaceEncodeManager face_encode_manager = FaceEncodeManager(args["detection_method"]) face_encode_manager.add_face(args["owner_name"], args["dataset"]) if args["sub_jobs"] == "self-update": from t_system.updation import Updater, install updater = Updater(args["verbose"]) updater.update() install(args["editable"])
def start_sub(args): """Function that starts the tracking system with the sub jobs according to command-line arguments. Args: args: Command-line arguments. """ if args["sub_jobs"] == "id": if args["id_sub_jobs"] == "set": t_system.identifier.change_keys(args["public_id"], args["private_id"], args["name"]) elif args["id_sub_jobs"] == "show": t_system.identifier.show_keys() elif args["sub_jobs"] == "remote-ui-authentication": t_system.administrator.change_keys(args["ssid"], args["password"]) elif args["sub_jobs"] == "encode-face": from t_system.face_encoding import FaceEncodeManager face_encode_manager = FaceEncodeManager(args["detection_method"]) face_encode_manager.add_face(args["owner_name"], args["dataset"]) elif args["sub_jobs"] == "self-update": t_system.update_manager.set_editability(args["editable"]) t_system.update_manager.set_verbosity(args["verbose"]) t_system.update_manager.update() elif args["sub_jobs"] == "arm": from t_system.motion.arm.modelisation import ArmModeler if args["arm_sub_jobs"] == "create": ArmModeler().create(args["name"]) elif args["arm_sub_jobs"] == "list": ArmModeler().show(args["name"]) elif args["sub_jobs"] == "live-stream": from t_system.online_stream import OnlineStreamer online_streamer = OnlineStreamer(None, None) if args["live_st_sub_jobs"] == "website": if args["live_st_website_sub_jobs"] == "upsert": online_streamer.add_website(args["name"], args["url"], args["server"], force_insert=True) elif args["live_st_website_sub_jobs"] == "remove": online_streamer.remove_websites(args["website_ids"]) elif args["live_st_website_sub_jobs"] == "list": online_streamer.show_websites() elif args["arm_sub_jobs"] == "streaming": if args["live_st_streaming_sub_jobs"] == "upsert": online_streamer.set_website_stream( args["website_id"], { "account_name": args["account_name"], "key": args["key"] }) elif args["live_st_streaming_sub_jobs"] == "remove": online_streamer.remove_website_stream(args["website_id"], args["account_name"]) elif args["live_st_streaming_sub_jobs"] == "list": online_streamer.show_stream_ids() elif args["sub_jobs"] == "r-sync": if args["list_services"]: t_system.r_synchronizer.show_services() elif args["r_sync_sub_jobs"] == "sync": t_system.r_synchronizer.start_sync(args["service_name"], args["name"]) elif args["r_sync_sub_jobs"] == "account": if args["r_sync_account_sub_jobs"] == "upsert": t_system.r_synchronizer.set_service_account( args["service_name"], { "name": args["name"], "key": args["key"] }) elif args["r_sync_account_sub_jobs"] == "remove": t_system.r_synchronizer.remove_service_account( args["service_name"], args["name"]) elif args["r_sync_account_sub_jobs"] == "list": t_system.r_synchronizer.show_accounts() elif args["sub_jobs"] == "log": if args["show"]: import subprocess path, name = t_system.log_manager.get_logfile() subprocess.call(f'sudo nano {path}', shell=True) if args["clear"]: t_system.log_manager.clear_logs()
def prepare(args): """The function that prepares the working environment for storing data during running. Args: args: Command-line arguments. """ if args["interface"] == "official_stand" or args[ "interface"] == "remote_ui": elevate(show_console=False, graphical=False) if not os.path.exists(dot_t_system_dir): os.mkdir(dot_t_system_dir) from t_system.presentation import startup_banner startup_banner() t_system.log_manager = LogManager(args) global logger logger = t_system.log_manager.get_logger(__name__, "DEBUG") logger.info("Logger integration successful.") if args["ext_servo_driver"]: from adafruit_servokit import ServoKit t_system.motor_driver = ServoKit(channels=args["sd_channels"]) logger.info("Motors running on external driver.") from t_system.accession import NetworkConnector from t_system.administration import Identifier from t_system.administration import Administrator from t_system.updation import UpdateManager from t_system.motion.arm import Arm from t_system.motion.action import MissionManager from t_system.recordation import RecordManager from t_system.face_encoding import FaceEncodeManager from t_system.r_synchronization import RSynchronizer t_system.network_connector = NetworkConnector(args) t_system.identifier = Identifier() t_system.administrator = Administrator() t_system.update_manager = UpdateManager() t_system.arm = Arm(args["arm_name"], args["ext_servo_driver"]) t_system.mission_manager = MissionManager() t_system.record_manager = RecordManager() t_system.face_encode_manager = FaceEncodeManager() t_system.r_synchronizer = RSynchronizer() if not args["no_emotion"]: from t_system.motion.action import EmotionManager t_system.emotion_manager = EmotionManager() if args["sub_jobs"]: start_sub(args) sys.exit(1) if args["access_point"]: from t_system.accession import AccessPoint elevate(show_console=False, graphical=False) access_point = AccessPoint(args) access_point.start() if not args["AI"] or args["non_moving_target"]: if args["learn"]: raise Exception( 'All AI learning tools deprecated. Don\'t use the learn mode without AI.' ) logger.info("Package preparation completed.")