()
| 45 | return next(results, None) |
| 46 | |
| 47 | def init(): |
| 48 | run_checks() |
| 49 | from logic.capture import capture |
| 50 | from logic.visual import visuals |
| 51 | from logic.frame_parser import frameParser |
| 52 | from logic.hotkeys_watcher import hotkeys_watcher |
| 53 | from logic.shooting import shooting |
| 54 | |
| 55 | tracker = ByteTrackTracker() if not cfg.disable_tracker else None |
| 56 | |
| 57 | try: |
| 58 | model = YOLO(f"models/{cfg.AI_model_name}", task="detect") |
| 59 | except Exception as e: |
| 60 | logger.error(f"An error occurred when loading the AI model:\n{e}") |
| 61 | raise SystemExit(0) |
| 62 | |
| 63 | while True: |
| 64 | image = capture.get_new_frame() |
| 65 | |
| 66 | if image is None: |
| 67 | continue |
| 68 | |
| 69 | if cfg.circle_capture: |
| 70 | image = capture.convert_to_circle(image) |
| 71 | |
| 72 | if hotkeys_watcher.app_pause != 0: |
| 73 | visuals.clear() |
| 74 | shooting.shoot(False, False) |
| 75 | if cfg.show_window or cfg.show_overlay: |
| 76 | visuals.submit_frame(image) |
| 77 | continue |
| 78 | |
| 79 | result = perform_detection(model, image, tracker) |
| 80 | frameParser.parse(result) |
| 81 | |
| 82 | if cfg.show_window or cfg.show_overlay: |
| 83 | visuals.submit_frame(image) |
| 84 | |
| 85 | if __name__ == "__main__": |
| 86 | init() |
no test coverage detected