mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-25 10:05:49 +08:00
更新地图特征点路径和UI文本,地图追踪时添加自动拾取 在 `FeatureStorage.cs` 中,将 `rootPath` 的路径从 `Global.Absolute(@"User\Map\");` 修改为 `Global.Absolute(@"Assets\Map\");`。 在 `Navigation.cs` 中,更新了日志信息的内容,使其更加明确首次加载速度较慢。 在 `BigMap.cs` 中,将 `FeatureMatcher` 的初始化参数从 `MapAssets.Instance.MainMap256BlockMat.Value` 修改为 `new Size(4096, 3328)`。 在 `MapPathingPage.xaml` 中,更新了部分 UI 文本,使其更加准确和清晰。例如,将“查看地图”修改为“查看实时追踪地图”,并在功能描述中添加了“尝鲜”字样。 在 `MapPathingPage.xaml` 中,注释掉了一个 `GridViewColumn`,该列包含了一个操作按钮。 在 `MapPathingViewModel.cs` 中,添加了 `using BetterGenshinImpact.Core.Script.Dependence.Model;` 引用。 在 `MapPathingViewModel.cs` 中,修改了 `TaskRunner` 的初始化参数,并在执行路径任务前添加了一个触发器。 在 `PickHandler.cs` 中,添加了一个新的类 `PickHandler`,并标记为 `[Obsolete]`,表示该类暂时不需要。
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using BetterGenshinImpact.Core.Recognition.OpenCv;
|
|
using BetterGenshinImpact.Core.Recognition.OpenCv.FeatureMatch;
|
|
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
|
using BetterGenshinImpact.Model;
|
|
using OpenCvSharp;
|
|
using System.Diagnostics;
|
|
|
|
namespace BetterGenshinImpact.GameTask.Common.Map;
|
|
|
|
/// <summary>
|
|
/// 专门用于大地图的识别
|
|
/// 图像缩小了8倍
|
|
/// </summary>
|
|
public class BigMap : Singleton<BigMap>
|
|
{
|
|
// 直接从图像加载特征点
|
|
private readonly FeatureMatcher _featureMatcher = new(new Size(4096, 3328), new FeatureStorage("mainMap256Block"));
|
|
|
|
// 相对标准1024区块的缩放比例
|
|
public const int ScaleTo1024 = 4;
|
|
|
|
// 相对2048区块的缩放比例
|
|
public const int ScaleTo2048 = ScaleTo1024 * 2;
|
|
|
|
/// <summary>
|
|
/// 基于特征匹配获取地图位置 全部匹配
|
|
/// </summary>
|
|
/// <param name="greyMat">传入的大地图图像会缩小8倍</param>
|
|
/// <returns></returns>
|
|
public Point2f GetBigMapPositionByFeatureMatch(Mat greyMat)
|
|
{
|
|
try
|
|
{
|
|
greyMat = ResizeHelper.Resize(greyMat, 1d / 4);
|
|
|
|
return _featureMatcher.Match(greyMat);
|
|
}
|
|
catch
|
|
{
|
|
Debug.WriteLine("Feature Match Failed");
|
|
return new Point2f();
|
|
}
|
|
}
|
|
|
|
public Rect GetBigMapRectByFeatureMatch(Mat greyMat)
|
|
{
|
|
try
|
|
{
|
|
greyMat = ResizeHelper.Resize(greyMat, 1d / 4);
|
|
|
|
return _featureMatcher.KnnMatchRect(greyMat);
|
|
}
|
|
catch
|
|
{
|
|
Debug.WriteLine("Feature Match Failed");
|
|
return Rect.Empty;
|
|
}
|
|
}
|
|
}
|