Skip to content

ch3n0297/AimAssistSystem_CV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aim Assist System

基於 YOLOv11n 的 2D 遊戲輔助瞄準系統,專為研究與教學用途設計。

⚠️ 免責聲明: 本系統僅供研究、教學與技術展示用途,不鼓勵、不支援任何形式的遊戲作弊行為。

功能特色

  • 🎯 即時敵人偵測: 使用 YOLOv11n 模型進行高效能目標偵測
  • 🖱️ 平滑準星移動: PD 控制器 + α-β 平滑演算法,避免瞬移
  • 🖼️ 透明 Overlay: 顯示偵測框、FPS、延遲等資訊
  • 低延遲: GPU 推論 ~3ms,端到端延遲 <100ms
  • ⚙️ 可調參數: 透過 YAML 設定檔自訂控制器行為

系統需求

  • 作業系統: Windows 10/11 或 Linux (X11)
  • Python: 3.8+
  • GPU: NVIDIA GPU (可選,支援 CUDA 12.x)
  • CPU: 支援純 CPU 模式(自動偵測)
  • 螢幕解析度: 1920×1080

安裝

1. 建立虛擬環境

Linux:

cd /path/to/AimAssistSystem
python3 -m venv venv
source venv/bin/activate

Windows:

cd C:\path\to\AimAssistSystem
python -m venv venv
venv\Scripts\activate

2. 安裝依賴

pip install -r requirements.txt

3. 放置模型檔案

將訓練好的模型 best.pt 放入 model/ 目錄:

AimAssistSystem/
└── model/
    └── best.pt

4. 確認環境(可選)

# 檢查是否有 GPU(沒有也可以運行)
python -c "import torch; print(f'CUDA: {torch.cuda.is_available()}')"

使用方式

啟動系統

python main.py

系統會自動偵測硬體並選擇最佳配置:

  • 有 NVIDIA GPU → 使用 config.yaml (GPU 優化)
  • 無 GPU / 僅 CPU → 使用 config_cpu.yaml (CPU 優化)

命令列參數

# 自動偵測(推薦)
python main.py

# 強制使用 GPU 配置
python main.py --config config.yaml

# 強制使用 CPU 配置
python main.py --config config_cpu.yaml

# 不顯示 Overlay(除錯用)
python main.py --no-overlay

操作說明

  1. 開啟瀏覽器,進入 ZombsRoyale.io
  2. 將遊戲設為全螢幕 (1920×1080)
  3. 執行 python main.py
  4. T 開啟 Aim Assist
  5. 系統會自動偵測敵人並平滑移動滑鼠

快捷鍵

按鍵 功能
T 切換 Aim Assist 開關
ESC 退出程式

設定檔

系統提供兩種預設配置:

配置檔 用途 預期 FPS
config.yaml GPU 用戶 60-120+
config_cpu.yaml CPU 用戶 5-15

GPU 配置 (config.yaml)

controller:
  kp: 0.25        # 比例係數
  kd: 0.08        # 微分係數
  alpha: 0.7      # 平滑係數
  dead_zone: 3    # 死區半徑
  max_speed: 50   # 最大移動速度

detection:
  device: "cuda"  # 使用 GPU

CPU 配置 (config_cpu.yaml)

controller:
  kp: 0.35        # 較高,補償低幀率
  kd: 0.05        # 較低,減少抖動
  alpha: 0.5      # 較低,更即時反應
  dead_zone: 5    # 較大,避免抖動
  max_speed: 80   # 較高,補償低幀率

detection:
  device: "cpu"   # 使用 CPU

參數調整建議

目標 調整方式
更快吸附 提高 kp、降低 alpha
更平滑 降低 kp、提高 alpha
減少抖動 提高 dead_zone、提高 alpha

專案結構

AimAssistSystem/
├── main.py              # 主程式入口
├── config.yaml          # GPU 用戶設定檔
├── config_cpu.yaml      # CPU 用戶設定檔(自動偵測)
├── requirements.txt     # Python 依賴
├── SPEC.md              # 系統規格文件
│
├── model/               # 模型目錄
│   └── best.pt          # YOLOv11n 權重檔
│
├── core/                # 核心模組
│   ├── capture.py       # 螢幕擷取
│   ├── detector.py      # YOLO 推論
│   ├── target_selector.py  # 目標選擇
│   ├── controller.py    # PD 控制器
│   └── mouse_control.py # 滑鼠控制
│
├── overlay/             # UI 模組
│   └── hud.py           # 透明 Overlay
│
├── utils/               # 工具模組
│   ├── coordinate.py    # 座標轉換
│   └── logger.py        # 日誌記錄
│
└── logs/                # 日誌輸出

效能指標

GPU 模式 (RTX 3060)

指標 數值
模型推論時間 ~3 ms
端到端延遲 <30 ms
系統 FPS >30 FPS

CPU 模式

指標 數值
模型推論時間 ~70-150 ms
端到端延遲 ~100-200 ms
系統 FPS 5-15 FPS

CPU 模式下 FPS 較低,但系統已針對低幀率優化控制器參數。

日誌與分析

系統會自動在 logs/ 目錄產生 CSV 日誌,包含:

  • 每幀偵測數量
  • 推論時間
  • 總延遲
  • FPS

可用於後續效能分析與研究。

疑難排解

模型載入失敗

確認模型檔案存在於 model/ 目錄:

# Linux
ls -la model/best.pt

# Windows
dir model\best.pt

CUDA 不可用(可選,系統會自動切換 CPU)

# 檢查 NVIDIA 驅動
nvidia-smi

# 確認 PyTorch CUDA 版本相容
python -c "import torch; print(torch.version.cuda)"

pynput/PyQt5 錯誤 (Linux)

確保在有 X11 顯示的環境下執行:

echo $DISPLAY  # 應該顯示 :0 或類似值

Windows 上 Overlay 不顯示

確認以系統管理員身分執行,部分遊戲的反作弊可能會阻擋 Overlay。

授權

本專案僅供學術研究與教學用途。

About

Just want to have fun, make a python code to assist aim for player when they playing.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages