mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-06-02 10:55:48 +08:00
* 更新多个NuGet包至最新版本 * 重构模型加载以适应yolosharp * feat: 改变接口。TensorRT缓存的初步支持,修改配置项。 * 更新依赖并调整变量顺序,修复加载问题 * 更新AvalonEdit和Microsoft.ML.OnnxRuntime包至最新版本,以修复问题 * fix: downgrade Microsoft.ML.OnnxRuntime.DirectML to version 1.21.0 * typo * fix: change log level from warning to error for ONNX provider loading failure * 增加 paddle ocr 的 onnx 模型 * feat: add PaddleOCR models for Chinese, English, and Latin recognition * 使用cv的DNN生成Tensor,加速Yap文字识别 * feat: 尝试搓一个onnx的ocr * clean up code * chore: update OpenCvSharp4 package versions to 4.10.0.20241108 * 修复因格式化代码而丢的引用 * chore: update Microsoft.ML.OnnxRuntime.DirectML package to version 1.21.1 and improve logging for ONNX provider initialization * chore: 等yolosharp更新再升级onnx * chore: add Microsoft.ML.OnnxRuntime.Managed package and clean up logging in Det class * fix: refactor output tensor handling in Det class for improved clarity * 补充注释,修复DML的OCR问题 * 默认OCR推理使用CPU,整理配置 * fix error NETSDK1152: 找到了多个具有相同相对路径的发布输出文件 * fix(logging): enhance debug log for ONNX initialization with provider details * 修复TensorRT模型缓存的加载问题 * fix(onnx): improve cached model retrieval and add file existence check * fix(ocr): replace SrcGreyMat with SrcMat for region of interest processing * fix(onnx): add file existence check for cached model and adjust session options for DirectML provider * 增加硬件加速配置UI界面 * 移除旧的OCR模型 * 错别字 --------- Co-authored-by: 辉鸭蛋 <huiyadanli@gmail.com>
95 lines
4.7 KiB
C#
95 lines
4.7 KiB
C#
using BetterGenshinImpact.GameTask.AutoFishing;
|
|
using BehaviourTree;
|
|
using BetterGenshinImpact.GameTask.Model.Area;
|
|
using Microsoft.Extensions.Time.Testing;
|
|
using OpenCvSharp;
|
|
|
|
namespace BetterGenshinImpact.UnitTest.GameTaskTests.AutoFishingTests
|
|
{
|
|
public partial class BehavioursTests
|
|
{
|
|
[Theory]
|
|
[InlineData("20250225101257889_GetFishpond_Succeeded.png", new string[] { "medaka", "butterflyfish", "pufferfish", "stickleback" })]
|
|
[InlineData("202502252347412417.png", new string[] { "medaka", "koi", "koi head" })]
|
|
[InlineData("202502252350206390.png", new string[] { "phony unihornfish", "magma rapidfish" })]
|
|
/// <summary>
|
|
/// 测试各种鱼的获取,结果为成功
|
|
/// </summary>
|
|
public void GetFishpondTest_VariousFishExist_ShouldSuccess(string screenshot1080p, IEnumerable<string> fishNames)
|
|
{
|
|
//
|
|
Mat mat = new Mat(@$"..\..\..\Assets\AutoFishing\{screenshot1080p}");
|
|
var imageRegion = new GameCaptureRegion(mat, 0, 0, drawContent: new FakeDrawContent());
|
|
|
|
var blackboard = new Blackboard(Predictor, sleep: i => { });
|
|
|
|
//
|
|
GetFishpond sut = new GetFishpond("-", blackboard, new FakeLogger(), false, new FakeTimeProvider(), drawContent: new FakeDrawContent());
|
|
BehaviourStatus actualStatus = sut.Tick(imageRegion);
|
|
|
|
//
|
|
Assert.Equal(BehaviourStatus.Succeeded, actualStatus);
|
|
foreach (var g in fishNames.GroupBy(n => n))
|
|
{
|
|
string fishName = g.Key;
|
|
var fish = blackboard.fishpond.Fishes.Where(f => f.FishType.Name == fishName);
|
|
Assert.NotEmpty(fish);
|
|
}
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("20250225101257889_GetFishpond_Succeeded.png", new string[] { "fruit paste bait", "fruit paste bait", "redrot bait", "redrot bait" }, new string[] { "false worm bait", "false worm bait", "fake fly bait", "fake fly bait" })]
|
|
/// 测试鱼的鱼饵均在失败列表中且被忽略,结果为运行中
|
|
/// </summary>
|
|
public void GetFishpondTest_AllIgnored_ShouldBeRunning(string screenshot1080p, IEnumerable<string> chooseBaitfailures, IEnumerable<string> throwRodNoTargetFishfailures)
|
|
{
|
|
//
|
|
Mat mat = new Mat(@$"..\..\..\Assets\AutoFishing\{screenshot1080p}");
|
|
var imageRegion = new GameCaptureRegion(mat, 0, 0, drawContent: new FakeDrawContent());
|
|
|
|
var blackboard = new Blackboard(Predictor, sleep: i => { });
|
|
blackboard.chooseBaitFailures = chooseBaitfailures.ToList();
|
|
blackboard.throwRodNoBaitFishFailures = throwRodNoTargetFishfailures.ToList();
|
|
|
|
//
|
|
GetFishpond sut = new GetFishpond("-", blackboard, new FakeLogger(), false, new FakeTimeProvider(), drawContent: new FakeDrawContent());
|
|
BehaviourStatus actualStatus = sut.Tick(imageRegion);
|
|
|
|
//
|
|
Assert.Equal(BehaviourStatus.Running, actualStatus);
|
|
Assert.NotEmpty(blackboard.fishpond.Fishes);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("20250225101257889_GetFishpond_Succeeded.png", "medaka", 1)]
|
|
[InlineData("20250301192848793_GetFishpond_Succeeded.png", "medaka", 2)]
|
|
[InlineData("20250226161354285_ChooseBait_Succeeded.png", "medaka", 0)]
|
|
[InlineData("202503012143011486@900p.png", "medaka", 0)]
|
|
[InlineData("20250301231059172_GetFishpond_Succeeded.png", "medaka", 0)]
|
|
[InlineData("20250301234659009_GetFishpond_Succeeded.png", "axe marlin", 2)]
|
|
[InlineData("20250301235638915_GetFishpond_Succeeded.png", "butterflyfish", 1)]
|
|
[InlineData("20250302001049589_GetFishpond_Succeeded.png", "axe marlin", 0)]
|
|
[InlineData("20250306165029475_GetFishpond_Succeeded.png", "butterflyfish", 0)]
|
|
[InlineData("20250306171545590_GetFishpond_Succeeded.png", "heartfeather bass", 0)]
|
|
/// <summary>
|
|
/// 测试各种鱼的获取数量,数量应相符
|
|
/// </summary>
|
|
public void GetFishpondTest_FishCount_ShouldSuccess(string screenshot1080p, string fishName, int count)
|
|
{
|
|
//
|
|
Mat mat = new Mat(@$"..\..\..\Assets\AutoFishing\{screenshot1080p}");
|
|
var imageRegion = new GameCaptureRegion(mat, 0, 0, drawContent: new FakeDrawContent());
|
|
|
|
var blackboard = new Blackboard(Predictor, sleep: i => { });
|
|
|
|
//
|
|
GetFishpond sut = new GetFishpond("-", blackboard, new FakeLogger(), false, new FakeTimeProvider(), drawContent: new FakeDrawContent());
|
|
sut.Tick(imageRegion);
|
|
int actual = blackboard.fishpond?.Fishes?.Count(f => f.FishType.Name == fishName) ?? 0;
|
|
|
|
//
|
|
Assert.Equal(count, actual);
|
|
}
|
|
}
|
|
}
|