Skip to content

Conversation

@1004452714
Copy link
Contributor

#2303

在检测角色弹窗的方法中添加了debug日志,为了防止刷日志,将面积检查放在了最前边。

简单测试日常NPC对话中,在面积检查这一步就跳过了。再加上自动剧情的前置条件,应该没问题。

@huiyadanli huiyadanli merged commit 716ceb2 into babalae:main Oct 7, 2025
1 check passed
@1004452714 1004452714 deleted the AutoSkip branch October 7, 2025 16:28
kaedelcb pushed a commit to kaedelcb/better-genshin-impact that referenced this pull request Oct 10, 2025
@zaodonganqi
Copy link
Contributor

CloseCharacterPopup在1080p以下时会有问题(鸭蛋述)
这样的检测范围能对多种分辨率适配吗(我个人疑问)

@1004452714
Copy link
Contributor Author

CloseCharacterPopup在1080p以下时会有问题(鸭蛋述) 这样的检测范围能对多种分辨率适配吗(我个人疑问)

完全不适配!主要我以为BGI只支持1080p,其次是这个界面也不方便测试,没有获得足够的多分辨率样本图片。(不想推剧情)

        Cv2.Rectangle(srcMat, new Rect(240, 395, 300, 50), new Scalar(229, 241, 245), -1);
        Cv2.Rectangle(srcMat, new Rect(290, 660, 210, 40), new Scalar(101, 82, 74), -1);

问题在闭合矩形的Rect是写死的位置,只针对1920*1080这个分辨率
如果其他16:9分辨率这个界面只是等比缩放,把Rect的参数按比例缩放就可以适配

数值示例

// 获取当前图像的实际宽高
int currentWidth = srcMat.Cols;
int currentHeight = srcMat.Rows;

// 1920×1080分辨率下的原始比例计算
// 第一个矩形:Rect(240, 395, 300, 50)
double x1Ratio = 240.0 / 1920;   // 0.125
double y1Ratio = 395.0 / 1080;   // ~0.3657
double w1Ratio = 300.0 / 1920;   // 0.15625
double h1Ratio = 50.0 / 1080;    // ~0.0463

// 第二个矩形:Rect(290, 660, 210, 40)
double x2Ratio = 290.0 / 1920;   // ~0.1510
double y2Ratio = 660.0 / 1080;   // ~0.6111
double w2Ratio = 210.0 / 1920;   // ~0.1094
double h2Ratio = 40.0 / 1080;    // ~0.0370

// 计算当前分辨率下的坐标
int x1 = (int)(x1Ratio * currentWidth);
int y1 = (int)(y1Ratio * currentHeight);
int width1 = (int)(w1Ratio * currentWidth);
int height1 = (int)(h1Ratio * currentHeight);

int x2 = (int)(x2Ratio * currentWidth);
int y2 = (int)(y2Ratio * currentHeight);
int width2 = (int)(w2Ratio * currentWidth);
int height2 = (int)(h2Ratio * currentHeight);

// 绘制适配当前分辨率的矩形
Cv2.Rectangle(srcMat, new Rect(x1, y1, width1, height1), new Scalar(229, 241, 245), -1);
Cv2.Rectangle(srcMat, new Rect(x2, y2, width2, height2), new Scalar(101, 82, 74), -1);

包括识别点击小道具也是针对1920*1080分辨率,像素面积固定在20-50之间,识别区域限定在(945, 1040, 30, 20)
理论上删掉面积阈值判定,再把DeriveCrop参数改一下就完全没问题。

这个示例数值在25601440跟19201080分辨率上测试可用

int currentWidth = content.CaptureRectArea.SrcMat.Cols;
int currentHeight = content.CaptureRectArea.SrcMat.Rows;
int x = (int)(currentWidth / 2 - currentWidth * 0.02);  
int y = (int)(currentHeight * 0.94);  
int w = (int)(currentWidth * 0.04);  
int h = currentHeight - y; 
using var croppedRegion = content.CaptureRectArea.DeriveCrop(x, y, w, h);

@zaodonganqi
Copy link
Contributor

那就只能通过检测图像的方式来适配分辨率了

@huiyadanli
Copy link
Member

写死的位置乘以 SystemInfo.AssetScale 就行了,比直接比例算要简单些。

参考其他模板匹配资源文件的坐标比例转换

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants