diff --git a/README.md b/README.md index b2c0453..3c62db0 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@ 2. 等待扫描设备(设备越多等待时间越长) 3. 选择客户端 4. 输入需要执行的任务序号 - - 以空格分隔,例如 `1 2 3 4 5` 和 `2 3 1 4 5`,序号的顺序代表着执行顺序 - 序号可重复,例如 `5 1 2 3 4 5` @@ -73,6 +72,9 @@ - 目前启动游戏仅支持官服、Bilibili服和Vivo服 - 其他渠道服虽不支持启动,但可手动启动游戏后正常使用 - 若需要适配启动其他渠道服,欢迎提 `issues` 或 `pr` + - 家园远征可能会清空当前体力和家园体力罐内体力,总量受远征派遣体力限制 + - 如果任务列表中同时包含 MaterialEvent 和 Homelad,先完成 MaterialEvent是一个更好的选择。这样做有助于确保有足够的体力来完成所有任务 + - 使用材料减负需要先三星通关一次对应关卡,有多个关卡的模块(如曜日材料)则会自动进行已完成挑战的最高一级关卡 ## How to build diff --git a/tools/CropRoi/main.py b/tools/CropRoi/main.py index 3eed29e..ecbf522 100644 --- a/tools/CropRoi/main.py +++ b/tools/CropRoi/main.py @@ -2,10 +2,12 @@ import os from typing import List, Tuple -print("Usage:\n" - "Put the 16:9 images under ./src, and run this script, it will be auto converted to 720p.\n" - "Drag mouse to select ROI, press 'S' to save, press 'Q' to quit.\n" - "The cropped images will be saved in ./dst\n") +print( + "Usage:\n" + "Put the 16:9 images under ./src, and run this script, it will be auto converted to 720p.\n" + "Drag mouse to select ROI, press 'S' to save, press 'Q' to quit.\n" + "The cropped images will be saved in ./dst\n" +) # 初始化参考点列表和布尔值标志:是否正在执行裁剪 refPt: List[Tuple[int, int]] = [] @@ -26,6 +28,13 @@ def click_and_crop(event: int, x: int, y: int, *args) -> None: if event == cv2.EVENT_LBUTTONDOWN: refPt = [(x, y)] cropping = True + # 检测鼠标是否移动 + elif event == cv2.EVENT_MOUSEMOVE: + if cropping: + # 创建图像副本以绘制动态矩形 + draw = image.copy() + cv2.rectangle(draw, refPt[0], (x, y), (0, 255, 0), 2) + cv2.imshow("image", draw) # 检测鼠标左键是否释放 elif event == cv2.EVENT_LBUTTONUP: # 记录结束(x,y)坐标,并显示裁剪结束 @@ -73,36 +82,37 @@ def click_and_crop(event: int, x: int, y: int, *args) -> None: # 如果参考点列表里有俩个点,则裁剪区域并展示 if len(refPt) == 2: - if refPt[0][0] > refPt[1][0] or refPt[0][1] > refPt[1][1]: - refPt[0], refPt[1] = refPt[1], refPt[0] - left = refPt[0][0] - right = refPt[1][0] - top = refPt[0][1] - bottom = refPt[1][1] + pt1, pt2 = sorted(refPt) + + left, top = pt1 + right, bottom = pt2 roi = image[top:bottom, left:right] horizontal_expansion = 100 vertical_expansion = 100 - filename_x: int = int(left - horizontal_expansion / 2) - filename_x = max(filename_x, 0) - filename_y: int = int(top - vertical_expansion / 2) - filename_y = max(filename_y, 0) - filename_w: int = (right - left) + horizontal_expansion - if filename_x + filename_w > dsize_width: - filename_w = dsize_width - filename_x - filename_h: int = (bottom - top) + vertical_expansion - if filename_y + filename_h > dsize_height: - filename_h = dsize_height - filename_y + # 计算扩展后的左上角坐标,并确保不超出图像边界 + filename_x = max(0, left - horizontal_expansion // 2) + filename_y = max(0, top - vertical_expansion // 2) + + # 计算扩展后的宽度和高度,并进行边界检查 + filename_w = min( + dsize_width - filename_x, (right - left) + horizontal_expansion + ) + filename_h = min(dsize_height - filename_y, (bottom - top) + vertical_expansion) - dst_filename: str = f'{filename}_{filename_x},{filename_y},{filename_w},{filename_h}.png' - print('dst:', dst_filename) + dst_filename: str = ( + f"{filename}_{filename_x},{filename_y},{filename_w},{filename_h}.png" + ) + print("dst:", dst_filename) - print(f"original roi: {left}, {top}, {right - left}, {bottom - top}, \n" - f"amplified roi: {filename_x}, {filename_y}, {filename_w}, {filename_h}\n\n") + print( + f"original roi: {left}, {top}, {right - left}, {bottom - top}, \n" + f"amplified roi: {filename_x}, {filename_y}, {filename_w}, {filename_h}\n\n" + ) - cv2.imwrite(f'./dst/{dst_filename}', roi) + cv2.imwrite(f"./dst/{dst_filename}", roi) refPt: List[Tuple[int, int]] = [] cropping = False