def main(): parser = argparse.ArgumentParser() parser.add_argument("--model", default="assets/models/cnn_113_80_quantized.tflite") parser.add_argument("--checkpoint", action="store_true") parser.add_argument("--large", action="store_true") args = parser.parse_args() from load_model import load_any_model_filepath model, (HEIGHT, WIDTH) = load_any_model_filepath(args.model, not args.checkpoint, args.large) # screen box is (x, y, width, height) bounding_box = (677, 289, 322, 455) app = App() app.bounding_box = bounding_box callback = ImageCallback(*bounding_box[2:4]) app.image_callback = callback.on_image screenshotter = MSSScreenshot() # screenshotter = D3DScreenshot() predictor = Predictor(model, (HEIGHT, WIDTH)) predictor.acceleration = 2.5 def on_press(key): if key == Key.f1: print("[Resumed]") app.is_paused = False elif key == Key.f2: print("[Paused]") app.is_paused = True elif key == Key.f3: print("[Exit]") app.stop() # callback.stop_threads() elif key == Key.f4: callback.is_preview = not callback.is_preview print(f"[Preview={callback.is_preview}]") elif key == Key.f5: app.show_debug = not app.show_debug print("[Debug={0}]".format(app.show_debug)) elif key == Key.f6: app.track_only = not app.track_only print("[Track={0}]".format(app.track_only)) elif key == Key.f7: callback.is_recording = not callback.is_recording print(f"[Recording={callback.is_recording}]") input_listener = Listener(on_press=on_press) input_listener.start() display_controls() callback.start_threads() app.start(predictor, screenshotter) input_listener.stop() callback.stop_threads()
from src.app import App if __name__ == "__main__": app = App() app.start()