Feat Restrict screen recognition scope for different use cases
This commit is contained in:
parent
cca194160d
commit
6a96ab455a
@ -83,6 +83,7 @@ Wolf Chat 是一個基於 MCP (Modular Capability Provider) 框架的聊天機
|
|||||||
1. **泡泡檢測(含 Y 軸優先配對)**:通過辨識聊天泡泡的左上角 (TL) 和右下角 (BR) 角落圖案定位聊天訊息。
|
1. **泡泡檢測(含 Y 軸優先配對)**:通過辨識聊天泡泡的左上角 (TL) 和右下角 (BR) 角落圖案定位聊天訊息。
|
||||||
- **多外觀支援**:為了適應玩家可能使用的不同聊天泡泡外觀 (skin),一般用戶泡泡的偵測機制已被擴充,可以同時尋找多組不同的角落模板 (例如 `corner_tl_type2.png`, `corner_br_type2.png` 等)。機器人泡泡目前僅偵測預設的角落模板。
|
- **多外觀支援**:為了適應玩家可能使用的不同聊天泡泡外觀 (skin),一般用戶泡泡的偵測機制已被擴充,可以同時尋找多組不同的角落模板 (例如 `corner_tl_type2.png`, `corner_br_type2.png` 等)。機器人泡泡目前僅偵測預設的角落模板。
|
||||||
- **配對邏輯優化**:在配對 TL 和 BR 角落時,系統現在會優先選擇與 TL 角落 **Y 座標最接近** 的有效 BR 角落,以更好地區分垂直堆疊的聊天泡泡。
|
- **配對邏輯優化**:在配對 TL 和 BR 角落時,系統現在會優先選擇與 TL 角落 **Y 座標最接近** 的有效 BR 角落,以更好地區分垂直堆疊的聊天泡泡。
|
||||||
|
- **偵測區域限制 (2025-04-21)**:為了提高效率並減少誤判,聊天泡泡角落(`corner_*.png`, `bot_corner_*.png`)的圖像辨識**僅**在螢幕的特定區域 `(150, 330, 600, 880)` 內執行。其他 UI 元素的偵測(如按鈕、關鍵字等)不受此限制。
|
||||||
2. **關鍵字檢測**:在泡泡區域內搜尋 "wolf" 或 "Wolf" 關鍵字圖像。
|
2. **關鍵字檢測**:在泡泡區域內搜尋 "wolf" 或 "Wolf" 關鍵字圖像。
|
||||||
3. **內容獲取**:點擊關鍵字位置,使用剪貼板複製聊天內容。
|
3. **內容獲取**:點擊關鍵字位置,使用剪貼板複製聊天內容。
|
||||||
4. **發送者識別(含氣泡重新定位與偏移量調整)**:**關鍵步驟** - 為了提高在動態聊天環境下的穩定性,系統在獲取發送者名稱前,會執行以下步驟:
|
4. **發送者識別(含氣泡重新定位與偏移量調整)**:**關鍵步驟** - 為了提高在動態聊天環境下的穩定性,系統在獲取發送者名稱前,會執行以下步驟:
|
||||||
|
|||||||
@ -119,7 +119,7 @@ REPLY_BUTTON_IMG = os.path.join(TEMPLATE_DIR, "reply_button.png") # Added for re
|
|||||||
CHAT_INPUT_REGION = None # Example: (100, 800, 500, 50)
|
CHAT_INPUT_REGION = None # Example: (100, 800, 500, 50)
|
||||||
CHAT_INPUT_CENTER_X = 400
|
CHAT_INPUT_CENTER_X = 400
|
||||||
CHAT_INPUT_CENTER_Y = 1280
|
CHAT_INPUT_CENTER_Y = 1280
|
||||||
SCREENSHOT_REGION = None
|
SCREENSHOT_REGION = (70, 50, 800, 1365) # Updated region
|
||||||
CONFIDENCE_THRESHOLD = 0.9 # Increased threshold for corner matching
|
CONFIDENCE_THRESHOLD = 0.9 # Increased threshold for corner matching
|
||||||
STATE_CONFIDENCE_THRESHOLD = 0.7
|
STATE_CONFIDENCE_THRESHOLD = 0.7
|
||||||
AVATAR_OFFSET_X = -45 # Original offset, used for non-reply interactions like position removal
|
AVATAR_OFFSET_X = -45 # Original offset, used for non-reply interactions like position removal
|
||||||
@ -241,17 +241,20 @@ class DetectionModule:
|
|||||||
regular_tl_keys = ['corner_tl', 'corner_tl_type2', 'corner_tl_type3', 'corner_tl_type4'] # Added type4
|
regular_tl_keys = ['corner_tl', 'corner_tl_type2', 'corner_tl_type3', 'corner_tl_type4'] # Added type4
|
||||||
regular_br_keys = ['corner_br', 'corner_br_type2', 'corner_br_type3', 'corner_br_type4'] # Added type4
|
regular_br_keys = ['corner_br', 'corner_br_type2', 'corner_br_type3', 'corner_br_type4'] # Added type4
|
||||||
|
|
||||||
|
bubble_detection_region = (150, 330, 600, 880) # Define the specific region for bubbles
|
||||||
|
print(f"DEBUG: Using specific region for bubble corner detection: {bubble_detection_region}")
|
||||||
|
|
||||||
all_regular_tl_boxes = []
|
all_regular_tl_boxes = []
|
||||||
for key in regular_tl_keys:
|
for key in regular_tl_keys:
|
||||||
all_regular_tl_boxes.extend(self._find_template_raw(key))
|
all_regular_tl_boxes.extend(self._find_template_raw(key, region=bubble_detection_region)) # Pass region
|
||||||
|
|
||||||
all_regular_br_boxes = []
|
all_regular_br_boxes = []
|
||||||
for key in regular_br_keys:
|
for key in regular_br_keys:
|
||||||
all_regular_br_boxes.extend(self._find_template_raw(key))
|
all_regular_br_boxes.extend(self._find_template_raw(key, region=bubble_detection_region)) # Pass region
|
||||||
|
|
||||||
# --- Find Bot Bubble Corners (Raw Coordinates - Single Type) ---
|
# --- Find Bot Bubble Corners (Raw Coordinates - Single Type) ---
|
||||||
bot_tl_boxes = self._find_template_raw('bot_corner_tl') # Modified
|
bot_tl_boxes = self._find_template_raw('bot_corner_tl', region=bubble_detection_region) # Pass region
|
||||||
bot_br_boxes = self._find_template_raw('bot_corner_br') # Modified
|
bot_br_boxes = self._find_template_raw('bot_corner_br', region=bubble_detection_region) # Pass region
|
||||||
|
|
||||||
# --- Match Regular Bubbles (Any Type TL with Any Type BR) ---
|
# --- Match Regular Bubbles (Any Type TL with Any Type BR) ---
|
||||||
if all_regular_tl_boxes and all_regular_br_boxes:
|
if all_regular_tl_boxes and all_regular_br_boxes:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user