From fb79b03e03ecc6fa6e2d03fceeb7c34d46ddf3f9 Mon Sep 17 00:00:00 2001 From: MistEO Date: Sun, 1 Jan 2023 19:20:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=88=98=E6=96=97cd=E5=B9=B2=E5=91=98=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 12 ++++++++---- src/MaaCore/Task/BattleHelper.cpp | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index 958ddd6f46..5b49c89f9a 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -5984,13 +5984,17 @@ "postDelay": 500 }, "BattleAvatarData": { - "template": "empty.png", - "templThreshold": 0.6 - }, - "DiceAvatarMatch": { "template": "empty.png", "templThreshold": 0.8 }, + "BattleAvatarCoolingData": { + "template": "empty.png", + "templThreshold": 0.5, + "maskRange": [ + 0, + 50 + ] + }, "BattleKillsFlag": { "roi": [ 150, diff --git a/src/MaaCore/Task/BattleHelper.cpp b/src/MaaCore/Task/BattleHelper.cpp index 6940c6e5dc..8ee8ca1e20 100644 --- a/src/MaaCore/Task/BattleHelper.cpp +++ b/src/MaaCore/Task/BattleHelper.cpp @@ -139,6 +139,8 @@ bool asst::BattleHelper::update_deployment(bool init, const cv::Mat& reusable) m_cur_deployment_opers.clear(); const double threshold = Task.get("BattleAvatarData")->templ_threshold; + const double cooling_threshold = Task.get("BattleAvatarCoolingData")->templ_threshold; + const auto& cooling_mask_range = Task.get("BattleAvatarCoolingData")->mask_range; auto cur_opers = oper_analyzer.get_opers(); std::vector unknown_opers; @@ -159,10 +161,14 @@ bool asst::BattleHelper::update_deployment(bool init, const cv::Mat& reusable) for (auto& oper : cur_opers) { MatchImageAnalyzer avatar_analyzer; - avatar_analyzer.set_threshold(threshold); if (oper.cooling) { + Log.trace("start matching cooling", oper.index); + avatar_analyzer.set_threshold(cooling_threshold); // 把环去掉 - avatar_analyzer.set_mask_range(0, 50, true); + avatar_analyzer.set_mask_range(cooling_mask_range, true); + } + else { + avatar_analyzer.set_threshold(threshold); } avatar_analyzer.set_image(oper.avatar); @@ -184,8 +190,12 @@ bool asst::BattleHelper::update_deployment(bool init, const cv::Mat& reusable) remove_cooling_from_battlefield(oper); } else { + Log.info("unknown oper", oper.index); unknown_opers.emplace_back(oper); } + if (oper.cooling) { + Log.trace("stop matching cooling", oper.index); + } } if (!unknown_opers.empty() || init) { @@ -204,6 +214,7 @@ bool asst::BattleHelper::update_deployment(bool init, const cv::Mat& reusable) } while (!m_inst_helper.need_exit()); for (auto& oper : unknown_opers) { + LogTraceScope("rec unknown oper: " + std::to_string(oper.index)); click_oper_on_deployment(oper.rect); OcrWithPreprocessImageAnalyzer name_analyzer(m_inst_helper.ctrler()->get_image());