From 4813ed08aaaa36d22930bf6eba248bcf3676f8f2 Mon Sep 17 00:00:00 2001 From: status102 Date: Sun, 3 Sep 2023 16:22:26 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=A8=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E4=B8=A2=E5=A4=B1=E5=88=86=E9=9A=94=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Task/Fight/SanityBeforeStagePlugin.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp index a04f0279d4..95c0ffea14 100644 --- a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp +++ b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp @@ -2,11 +2,11 @@ #include +#include "Config/TaskData.h" +#include "Controller/Controller.h" #include "Utils/ImageIo.hpp" #include "Utils/Logger.hpp" #include "Vision/OCRer.h" -#include "Controller/Controller.h" -#include "Config/TaskData.h" bool asst::SanityBeforeStagePlugin::verify(AsstMsg msg, const json::value& details) const { @@ -24,7 +24,8 @@ bool asst::SanityBeforeStagePlugin::verify(AsstMsg msg, const json::value& detai } } -bool asst::SanityBeforeStagePlugin::_run() { +bool asst::SanityBeforeStagePlugin::_run() +{ LogTraceFunction; get_sanity(); @@ -44,11 +45,23 @@ void asst::SanityBeforeStagePlugin::get_sanity() analyzer.set_task_info("SanityMatch"); if (!analyzer.analyze()) { + Log.info("__FUNCTION__", "Current Sanity analyze failed"); return; } auto text = analyzer.get_result().front().text; - Log.info("Current Sanity:" + text); + Log.info("__FUNCTION__", "Current Sanity:" + text); + if (!text.find('/')) { + if (text.ends_with(' ')) { + text = text.substr(0, text.find_last_not_of(' ') + 1); + } + if (text[text.length() - 3] == '1' && text[text.length() - 2] <= '3') { + text = text.substr(0, text.length() - 3) + '/' + text.substr(text.length() - 3); + } + else { + text = text.substr(0, text.length() - 2) + '/' + text.substr(text.length() - 2); + } + } json::value sanity_info = basic_info_with_what("SanityBeforeStage"); sanity_info["details"]["sanity"] = text; From 1bb121d39387e8c4e9ec58942342dc0d3b341f4a Mon Sep 17 00:00:00 2001 From: status102 Date: Mon, 4 Sep 2023 12:00:40 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E4=B8=8B=E6=A0=87=E8=B6=8A=E7=95=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E8=AF=86=E5=88=AB=E7=BB=93=E6=9E=9C=E5=88=86?= =?UTF-8?q?=E5=9D=97=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp index 95c0ffea14..0749f83319 100644 --- a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp +++ b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp @@ -48,13 +48,14 @@ void asst::SanityBeforeStagePlugin::get_sanity() Log.info("__FUNCTION__", "Current Sanity analyze failed"); return; } - auto text = analyzer.get_result().front().text; + auto result = analyzer.get_result(); + auto text = std::string(""); + for (auto it = result.begin(); it != result.end(); it++) { + text = text + it->text; + } Log.info("__FUNCTION__", "Current Sanity:" + text); - if (!text.find('/')) { - if (text.ends_with(' ')) { - text = text.substr(0, text.find_last_not_of(' ') + 1); - } + if (!text.find('/') && text.length() > 3) { if (text[text.length() - 3] == '1' && text[text.length() - 2] <= '3') { text = text.substr(0, text.length() - 3) + '/' + text.substr(text.length() - 3); } From 5d08ac68577115a2d3e54c1de0c5e6a3d0239444 Mon Sep 17 00:00:00 2001 From: status102 Date: Mon, 4 Sep 2023 16:22:40 +0800 Subject: [PATCH 3/4] =?UTF-8?q?perf:=20=E4=BB=8EOCRer=E6=94=B9=E4=B8=BAReg?= =?UTF-8?q?ionOCRer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Task/Fight/SanityBeforeStagePlugin.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp index 0749f83319..6655d0ce31 100644 --- a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp +++ b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp @@ -7,6 +7,7 @@ #include "Utils/ImageIo.hpp" #include "Utils/Logger.hpp" #include "Vision/OCRer.h" +#include bool asst::SanityBeforeStagePlugin::verify(AsstMsg msg, const json::value& details) const { @@ -40,22 +41,17 @@ void asst::SanityBeforeStagePlugin::get_sanity() { LogTraceFunction; - // 直接摘抄博朗台部分,DrGrandetTaskPlugin - OCRer analyzer(ctrler()->get_image()); + RegionOCRer analyzer(ctrler()->get_image()); analyzer.set_task_info("SanityMatch"); if (!analyzer.analyze()) { - Log.info("__FUNCTION__", "Current Sanity analyze failed"); + Log.info(__FUNCTION__, "Current Sanity analyze failed"); return; } - auto result = analyzer.get_result(); - auto text = std::string(""); - for (auto it = result.begin(); it != result.end(); it++) { - text = text + it->text; - } + std::string text = analyzer.get_result().text; - Log.info("__FUNCTION__", "Current Sanity:" + text); - if (!text.find('/') && text.length() > 3) { + Log.info(__FUNCTION__, "Current Sanity:" + text); + if (!text.find('/') && text.length() > 2) { if (text[text.length() - 3] == '1' && text[text.length() - 2] <= '3') { text = text.substr(0, text.length() - 3) + '/' + text.substr(text.length() - 3); } From a17cfda4552b182ab6e4b4afe61c0d02ab1e9802 Mon Sep 17 00:00:00 2001 From: status102 Date: Mon, 4 Sep 2023 19:48:47 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E5=80=92=E6=95=B0?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E4=BD=8D>=3D'0'=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E7=A7=BB=E9=99=A4OCRer=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp index 6655d0ce31..00ec13e612 100644 --- a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp +++ b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp @@ -6,8 +6,7 @@ #include "Controller/Controller.h" #include "Utils/ImageIo.hpp" #include "Utils/Logger.hpp" -#include "Vision/OCRer.h" -#include +#include "Vision/RegionOCRer.h" bool asst::SanityBeforeStagePlugin::verify(AsstMsg msg, const json::value& details) const { @@ -50,15 +49,15 @@ void asst::SanityBeforeStagePlugin::get_sanity() } std::string text = analyzer.get_result().text; - Log.info(__FUNCTION__, "Current Sanity:" + text); if (!text.find('/') && text.length() > 2) { - if (text[text.length() - 3] == '1' && text[text.length() - 2] <= '3') { + if (text[text.length() - 3] == '1' && text[text.length() - 2] >= '0' && text[text.length() - 2] <= '3') { text = text.substr(0, text.length() - 3) + '/' + text.substr(text.length() - 3); } else { text = text.substr(0, text.length() - 2) + '/' + text.substr(text.length() - 2); } } + Log.info(__FUNCTION__, "Current Sanity:" + text); json::value sanity_info = basic_info_with_what("SanityBeforeStage"); sanity_info["details"]["sanity"] = text;