From 31ece8dc1cc53387ee3c06248c4e1a5a902abbec Mon Sep 17 00:00:00 2001 From: Rcmcpe Date: Sat, 11 Jul 2020 22:40:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7ImageLocator=E4=BB=A5?= =?UTF-8?q?=E6=94=B9=E5=96=84=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Arknights Automation Library/Assets.cs | 10 +++++----- Arknights Automation Library/Interactor.cs | 2 +- ImageLocator | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Arknights Automation Library/Assets.cs b/Arknights Automation Library/Assets.cs index f641c7a..44f2a81 100644 --- a/Arknights Automation Library/Assets.cs +++ b/Arknights Automation Library/Assets.cs @@ -1,30 +1,30 @@ using System; +using System.Collections.Generic; using System.IO; using OpenCvSharp; -using REVUnit.ImageLocator; namespace REVUnit.AutoArknights.Core { public class Assets : IDisposable { - private readonly Cache _cache = new Cache(); + private readonly Dictionary _memoryCacheMap = new Dictionary(); public void Dispose() { - foreach (Mat mat in _cache.CachedItems) mat.Dispose(); + foreach (Mat mat in _memoryCacheMap.Values) mat.Dispose(); } public Mat Get(string expr) { expr = expr.Trim(); - if (!_cache.Get(expr, out Mat mat)) + if (!_memoryCacheMap.TryGetValue(expr, out Mat mat)) { string fileName = GetFileName(expr); if (!File.Exists(fileName)) throw new IOException($"Asset not found: {expr}"); mat = Utils.Imread(fileName); if (mat.Empty()) throw new IOException($"Invalid asset: {expr}"); - _cache.Register(expr, mat); + _memoryCacheMap.Add(expr, mat); } return mat; diff --git a/Arknights Automation Library/Interactor.cs b/Arknights Automation Library/Interactor.cs index dfdac41..d9bf2fd 100644 --- a/Arknights Automation Library/Interactor.cs +++ b/Arknights Automation Library/Interactor.cs @@ -16,7 +16,7 @@ public class Interactor : IDisposable private readonly Adb _adb; private readonly Assets _assets = new Assets(); - private readonly FMLocator _loc = new FMLocator(new Feature2DInfo(Feature2Ds.Sift), "Assets\\Cache"); + private readonly FMLocator _loc = new FMLocator(Feature2DType.Sift, "Assets\\Cache"); public Interactor(string adbPath) { diff --git a/ImageLocator b/ImageLocator index f2b441a..7bd851a 160000 --- a/ImageLocator +++ b/ImageLocator @@ -1 +1 @@ -Subproject commit f2b441a46eaf912522c2a7346cef695101610e13 +Subproject commit 7bd851af2ff01c7861b1cc10afd47cc358c4237d