diff --git a/monitor.py b/monitor.py index 707f825..902c9dc 100644 --- a/monitor.py +++ b/monitor.py @@ -269,6 +269,16 @@ class MessageMonitor: pass self._emergency_thread.join(timeout=2) self._emergency_thread = None + # 杀死 EasyOCR 子进程(防止 GPU 推理残留吃资源/冻电脑) + try: + if self._easyocr_proc and self._easyocr_proc.poll() is None: + self._easyocr_proc.kill() + self._easyocr_proc.wait(timeout=3) + logger.info("[stop] EasyOCR 子进程已杀死") + except Exception as e: + logger.debug(f"[stop] 杀 EasyOCR 异常: {e}") + self._easyocr_proc = None + # 释放钩子回调引用(防止 GC 延迟导致卸载后崩溃) if hasattr(self, '_esc_hook_proc'): del self._esc_hook_proc @@ -3519,8 +3529,13 @@ class MessageMonitor: if re.match(r'^/[A-Za-z]', ts): logger.debug(f"[{platform}] Poll过滤: 斜线英文命令 ts={ts!r}") continue - # === OCR 误读斜线为 I/J:"/sdfl"→"Isdfl", "/import"→"Jimport" === - if re.match(r'^[A-Za-z]', ts) and ('sdfl' in ts.lower() or 'sdf1' in ts.lower()): + # === 下划线+斜线:OCR 左对齐气泡残影 "_ /sdfl undo" === + if re.match(r'^_[ /]', ts): + logger.debug(f"[{platform}] Poll过滤: 下划线斜线残影 ts={ts!r}") + continue + # === OCR 误读斜线为 I/J:"/sdfl"→"Isdfl", "_ /sdfl"→下划线前缀 === + # 常见变体:/sdfl, _ /sdfl, Isdfl, sdfl undo... + if 'sdfl' in ts.lower() or 'sdf1' in ts.lower(): logger.debug(f"[{platform}] Poll过滤: 变形命令(sdfl) ts={ts!r}") continue if re.match(r'^[A-Z][a-z]{4,}', ts) and re.search(r'[\u4e00-\u9fff]', ts) and len(ts) > 10: