Skip to content

Commit adb2b32

Browse files
committed
chore(deps): 去掉 opencv-python(不必要)+ 修 pyright agent→custom 遗漏
opencv-python 没必要:费用条 tick 用 numpy 向量化、头像/OCR 走 maafw C++ 识别、截图存盘用 Pillow(BGR→RGB 翻通道)。maafw 自带 OpenCV(C++)。 custom/main.py: cv2.imwrite → PIL Image.fromarray(image[...,::-1])(maafw 截图是 BGR)。 pyproject.toml: 去 opencv-python;pyright include/extraPaths 从 agent 改 custom(rename 时漏改)。 uv.lock: 重新生成(移除 opencv,共 15 包)。
1 parent 2337460 commit adb2b32

3 files changed

Lines changed: 274 additions & 6 deletions

File tree

custom/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,16 @@ def main() -> int:
105105

106106
out = paths["debug"] / "smoke.png"
107107
try:
108-
import cv2
109108
import numpy as np
109+
from PIL import Image
110110

111111
if isinstance(image, np.ndarray):
112-
cv2.imwrite(str(out), image)
112+
# maafw 返回 BGR(OpenCV 约定);PIL 要 RGB → 反转通道。
113+
rgb = np.ascontiguousarray(image[..., ::-1])
114+
Image.fromarray(rgb).save(str(out))
113115
logger.info("saved %s shape=%s dtype=%s", out, image.shape, image.dtype)
114116
else:
115-
logger.warning("image is not ndarray (type=%s); adjust save path", type(image).__name__)
117+
logger.warning("image is not ndarray (type=%s)", type(image).__name__)
116118
except Exception as e: # noqa: BLE001
117119
logger.exception("save failed: %r", e)
118120

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ description = "明日方舟自动凹图 — MaaFramework 方案二 (pipeline +
55
requires-python = ">=3.13,<3.14"
66
dependencies = [
77
"maafw>=0.0.0",
8-
"opencv-python>=4.10",
98
"numpy>=2.0",
109
"PySide6>=6.7",
1110
"websockets>=13.0",
@@ -33,7 +32,7 @@ line-length = 100
3332
select = ["E", "F", "I", "UP", "B"]
3433

3534
[tool.pyright]
36-
include = ["agent"]
37-
extraPaths = ["agent"]
35+
include = ["custom"]
36+
extraPaths = ["custom"]
3837
pythonVersion = "3.13"
3938
typeCheckingMode = "basic"

0 commit comments

Comments
 (0)