diff --git a/3rdparty/resource/PaddleCharOCR/det/inference.pdiparams b/3rdparty/resource/PaddleCharOCR/det/inference.pdiparams deleted file mode 100644 index 2efedca17f..0000000000 Binary files a/3rdparty/resource/PaddleCharOCR/det/inference.pdiparams and /dev/null differ diff --git a/3rdparty/resource/PaddleCharOCR/det/inference.pdmodel b/3rdparty/resource/PaddleCharOCR/det/inference.pdmodel deleted file mode 100644 index 0a6bf1e4ae..0000000000 Binary files a/3rdparty/resource/PaddleCharOCR/det/inference.pdmodel and /dev/null differ diff --git a/3rdparty/resource/PaddleCharOCR/det/version.txt b/3rdparty/resource/PaddleCharOCR/det/version.txt deleted file mode 100644 index 89a056fb9c..0000000000 --- a/3rdparty/resource/PaddleCharOCR/det/version.txt +++ /dev/null @@ -1 +0,0 @@ -en_PP-OCRv3_det_infer diff --git a/3rdparty/resource/PaddleCharOCR/keys.txt b/3rdparty/resource/PaddleCharOCR/keys.txt deleted file mode 100644 index 7677d31b9d..0000000000 --- a/3rdparty/resource/PaddleCharOCR/keys.txt +++ /dev/null @@ -1,95 +0,0 @@ -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -: -; -< -= -> -? -@ -A -B -C -D -E -F -G -H -I -J -K -L -M -N -O -P -Q -R -S -T -U -V -W -X -Y -Z -[ -\ -] -^ -_ -` -a -b -c -d -e -f -g -h -i -j -k -l -m -n -o -p -q -r -s -t -u -v -w -x -y -z -{ -| -} -~ -! -" -# -$ -% -& -' -( -) -* -+ -, -- -. -/ - diff --git a/3rdparty/resource/PaddleCharOCR/rec/inference.pdiparams b/3rdparty/resource/PaddleCharOCR/rec/inference.pdiparams deleted file mode 100644 index 26ba0c917d..0000000000 Binary files a/3rdparty/resource/PaddleCharOCR/rec/inference.pdiparams and /dev/null differ diff --git a/3rdparty/resource/PaddleCharOCR/rec/inference.pdmodel b/3rdparty/resource/PaddleCharOCR/rec/inference.pdmodel deleted file mode 100644 index 5dfe4cfa0a..0000000000 Binary files a/3rdparty/resource/PaddleCharOCR/rec/inference.pdmodel and /dev/null differ diff --git a/3rdparty/resource/PaddleCharOCR/rec/version.txt b/3rdparty/resource/PaddleCharOCR/rec/version.txt deleted file mode 100644 index 5ef569e1f8..0000000000 --- a/3rdparty/resource/PaddleCharOCR/rec/version.txt +++ /dev/null @@ -1 +0,0 @@ -en_PP-OCRv3_rec_infer diff --git a/resource/tasks.json b/resource/tasks.json index b27673885f..722d5812a4 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -185,7 +185,6 @@ "Doc": "base_task", "algorithm": "OcrDetect", "action": "ClickRect", - "isAscii": true, "text": [], "ocrReplace": [ [ @@ -348,7 +347,6 @@ "Doc": "base_task", "algorithm": "OcrDetect", "action": "Swipe", - "isAscii": true, "text": [], "ocrReplace": [ [ @@ -486,7 +484,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "fullMatch": true, - "isAscii": true, "cache": false, "text": [], "next": [ @@ -516,7 +513,6 @@ "algorithm": "OcrDetect", "action": "DoNothing", "fullMatch": true, - "isAscii": true, "cache": false, "text": [], "ocrReplace": [ @@ -700,7 +696,6 @@ "algorithm": "OcrDetect", "baseTask": "ChapterSlowlySwipeToTheLeft", "fullMatch": true, - "isAscii": true, "text": [ "1-8", "TR-10", @@ -726,7 +721,6 @@ "algorithm": "OcrDetect", "baseTask": "ChapterSlowlySwipeToTheRight", "fullMatch": true, - "isAscii": true, "text": [ "1-1", "1-2", @@ -756,7 +750,6 @@ "text": [ "1-7" ], - "isAscii": true, "cache": false, "roi": [ 0, @@ -888,7 +881,6 @@ "text": [ "IS-10" ], - "isAscii": true, "roi": [ 47, 42, @@ -903,7 +895,6 @@ "text": [ "IS-9" ], - "isAscii": true, "roi": [ 47, 42, @@ -918,7 +909,6 @@ "text": [ "IS-8" ], - "isAscii": true, "roi": [ 47, 42, @@ -994,7 +984,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "NL-10" ], @@ -1009,7 +998,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "NL-9" ], @@ -1024,7 +1012,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "NL-8" ], @@ -1078,7 +1065,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "GT-5" ] @@ -1147,7 +1133,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "OF-F3", "0F-F3" @@ -1157,7 +1142,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "OF-1", "0F-1" @@ -1227,7 +1211,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "IC-9", "1C-9" @@ -1243,7 +1226,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "IC-8", "1C-8" @@ -1259,7 +1241,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "IC-7", "1C-7" @@ -1345,7 +1326,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "DV-8" ], @@ -1360,7 +1340,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "DV-7" ], @@ -1375,7 +1354,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "DV-6" ], @@ -1452,7 +1430,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "LE-5" ], @@ -1467,7 +1444,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "LE-6" ], @@ -1482,7 +1458,6 @@ "algorithm": "OcrDetect", "action": "ClickSelf", "cache": false, - "isAscii": true, "text": [ "LE-7" ], @@ -1852,7 +1827,6 @@ "ChipStageLevel1": { "algorithm": "OcrDetect", "baseTask": "Stage", - "isAscii": true, "text": [], "roi": [ 27, @@ -1864,7 +1838,6 @@ "ChipStageLevel2": { "algorithm": "OcrDetect", "baseTask": "Stage", - "isAscii": true, "text": [], "roi": [ 472, @@ -3672,7 +3645,6 @@ }, "CreditShop-CreditOcr": { "algorithm": "OcrDetect", - "isAscii": true, "text": [], "roi": [ 1147, @@ -3762,7 +3734,6 @@ "RecruitTimerH": { "Doc": "识别公招小时数", "algorithm": "OcrDetect", - "isAscii": true, "withoutDet": true, "roi": [ 410, @@ -3785,7 +3756,6 @@ "RecruitTimerM": { "Doc": "识别公招分钟数", "algorithm": "OcrDetect", - "isAscii": true, "withoutDet": true, "roi": [ 575, @@ -5889,7 +5859,6 @@ }, "BattleKills": { "algorithm": "OcrDetect", - "isAscii": true, "text": [], "roi": [ 50, @@ -5900,7 +5869,6 @@ }, "BattleCostData": { "algorithm": "OcrDetect", - "isAscii": true, "text": [], "roi": [ 1196, @@ -6346,7 +6314,6 @@ "StageDrops-StageName": { "algorithm": "OcrDetect", "action": "DoNothing", - "isAscii": true, "text": [], "ocrReplace": [ [ @@ -6362,12 +6329,8 @@ "_INVALID_" ], [ - "Ap-", - "AP-" - ], - [ - "Bl-", - "BI-" + "—", + "-" ] ], "roi": [ @@ -6497,7 +6460,6 @@ }, "NumberOcrReplace": { "algorithm": "OcrDetect", - "isAscii": true, "text": [], "ocrReplace": [ [ @@ -6516,6 +6478,10 @@ "l", "1" ], + [ + "芳", + "万" + ], [ "方", "万" @@ -9151,4 +9117,4 @@ "RoguelikeWaitBattleStart" ] } -} +} \ No newline at end of file diff --git a/src/MaaCore/Common/AsstTypes.h b/src/MaaCore/Common/AsstTypes.h index 6c3e22fc0e..58fecefe0c 100644 --- a/src/MaaCore/Common/AsstTypes.h +++ b/src/MaaCore/Common/AsstTypes.h @@ -372,7 +372,6 @@ namespace asst OcrTaskInfo& operator=(OcrTaskInfo&&) noexcept = default; std::vector text; // 文字的容器,匹配到这里面任一个,就算匹配上了 bool full_match = false; // 是否需要全匹配,否则搜索到子串就算匹配上了 - bool is_ascii = false; // 是否启用字符数字模型 bool without_det = false; // 是否不使用检测模型 std::unordered_map replace_map; // 部分文字容易识别错,字符串强制replace之后,再进行匹配 diff --git a/src/MaaCore/Config/Miscellaneous/OcrPack.h b/src/MaaCore/Config/Miscellaneous/OcrPack.h index 5b77486a9b..daddc173a7 100644 --- a/src/MaaCore/Config/Miscellaneous/OcrPack.h +++ b/src/MaaCore/Config/Miscellaneous/OcrPack.h @@ -53,9 +53,4 @@ namespace asst { friend class SingletonHolder; }; - - class CharOcr final : public SingletonHolder, public OcrPack - { - friend class SingletonHolder; - }; } diff --git a/src/MaaCore/Config/ResourceLoader.cpp b/src/MaaCore/Config/ResourceLoader.cpp index 1b9d2fb1c9..11197f1d40 100644 --- a/src/MaaCore/Config/ResourceLoader.cpp +++ b/src/MaaCore/Config/ResourceLoader.cpp @@ -65,7 +65,7 @@ bool asst::ResourceLoader::load(const std::filesystem::path& path) /* load 3rd parties resource */ LoadResourceAndCheckRet(TilePack, "Arknights-Tile-Pos"_p / "levels.json"_p); LoadResourceAndCheckRet(WordOcr, "PaddleOCR"_p); - LoadResourceAndCheckRet(CharOcr, "PaddleCharOCR"_p); + // LoadResourceAndCheckRet(CharOcr, "PaddleCharOCR"_p); m_loaded = true; diff --git a/src/MaaCore/Config/TaskData.cpp b/src/MaaCore/Config/TaskData.cpp index 27bfd6fa35..3d524f1129 100644 --- a/src/MaaCore/Config/TaskData.cpp +++ b/src/MaaCore/Config/TaskData.cpp @@ -395,7 +395,6 @@ asst::TaskData::taskptr_t asst::TaskData::generate_ocr_task_info([[maybe_unused] #endif ocr_task_info_ptr->full_match = task_json.get("fullMatch", default_ptr->full_match); - ocr_task_info_ptr->is_ascii = task_json.get("isAscii", default_ptr->is_ascii); ocr_task_info_ptr->without_det = task_json.get("withoutDet", default_ptr->without_det); if (auto opt = task_json.find("ocrReplace")) { for (const json::value& rep : opt.value()) { @@ -534,7 +533,6 @@ std::shared_ptr asst::TaskData::_default_ocr_task_info() { auto ocr_task_info_ptr = std::make_shared(); ocr_task_info_ptr->full_match = false; - ocr_task_info_ptr->is_ascii = false; ocr_task_info_ptr->without_det = false; return ocr_task_info_ptr; diff --git a/src/MaaCore/MaaCore.vcxproj b/src/MaaCore/MaaCore.vcxproj index a4866360c2..261d7f4c93 100644 --- a/src/MaaCore/MaaCore.vcxproj +++ b/src/MaaCore/MaaCore.vcxproj @@ -39,6 +39,7 @@ + @@ -46,7 +47,6 @@ - @@ -153,6 +153,7 @@ + @@ -160,7 +161,6 @@ - diff --git a/src/MaaCore/MaaCore.vcxproj.filters b/src/MaaCore/MaaCore.vcxproj.filters index 5547a43a7f..63778883e1 100644 --- a/src/MaaCore/MaaCore.vcxproj.filters +++ b/src/MaaCore/MaaCore.vcxproj.filters @@ -153,9 +153,6 @@ 源文件\Vision\Roguelike - - 源文件\Vision\Roguelike - 源文件\Config @@ -426,6 +423,9 @@ 源文件 + + 源文件\Vision\Miscellaneous + @@ -488,9 +488,6 @@ 源文件\Vision\Roguelike - - 源文件\Vision\Roguelike - 源文件\Config @@ -707,5 +704,8 @@ 源文件 + + 源文件\Vision\Miscellaneous + \ No newline at end of file diff --git a/src/MaaCore/Task/Fight/DrGrandetTaskPlugin.cpp b/src/MaaCore/Task/Fight/DrGrandetTaskPlugin.cpp index 56e6484bdb..b5645f303e 100644 --- a/src/MaaCore/Task/Fight/DrGrandetTaskPlugin.cpp +++ b/src/MaaCore/Task/Fight/DrGrandetTaskPlugin.cpp @@ -1,9 +1,9 @@ #include "DrGrandetTaskPlugin.h" -#include "Controller.h" -#include "Vision/OcrImageAnalyzer.h" #include "Config/TaskData.h" +#include "Controller.h" #include "Utils/Logger.hpp" +#include "Vision/OcrImageAnalyzer.h" #include @@ -52,8 +52,6 @@ int asst::DrGrandetTaskPlugin::analyze_time_left() OcrImageAnalyzer analyzer(ctrler()->get_image()); analyzer.set_task_info("DrGrandetUseOriginiums"); analyzer.set_replace(Task.get("NumberOcrReplace")->replace_map); - // 这里是汉字和数字混合的,用不了单独的en模型 - analyzer.set_use_char_model(false); if (!analyzer.analyze()) { return -1; @@ -74,4 +72,4 @@ int asst::DrGrandetTaskPlugin::analyze_time_left() Log.info("Time left ms:", millisec); return millisec; -} \ No newline at end of file +} diff --git a/src/MaaCore/Vision/Roguelike/StageDropsImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp similarity index 96% rename from src/MaaCore/Vision/Roguelike/StageDropsImageAnalyzer.cpp rename to src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp index 775e1c7441..6f1a5e43b5 100644 --- a/src/MaaCore/Vision/Roguelike/StageDropsImageAnalyzer.cpp +++ b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp @@ -191,11 +191,7 @@ bool asst::StageDropsImageAnalyzer::analyze_drops() } std::string item = match_item(item_roi, drop_type, size - i, size); - bool use_word_model = item == LMD_ID; - int quantity = match_quantity(item_roi, use_word_model); - if (use_word_model && quantity == 0) { - quantity = match_quantity(item_roi, false); - } + int quantity = match_quantity(item_roi); Log.info("Item id:", item, ", quantity:", quantity); #ifdef ASST_DEBUG cv::rectangle(m_image_draw, make_rect(item_roi), cv::Scalar(0, 0, 255), 2); @@ -462,7 +458,7 @@ std::string asst::StageDropsImageAnalyzer::match_item(const Rect& roi, StageDrop return result; } -int asst::StageDropsImageAnalyzer::match_quantity(const Rect& roi, bool use_word_model) +int asst::StageDropsImageAnalyzer::match_quantity(const Rect& roi) { auto task_ptr = Task.get("StageDrops-Quantity"); @@ -522,7 +518,6 @@ int asst::StageDropsImageAnalyzer::match_quantity(const Rect& roi, bool use_word analyzer.set_roi(Rect(quantity_roi.x + far_left, quantity_roi.y, far_right - far_left, quantity_roi.height)); analyzer.set_expansion(1); analyzer.set_threshold(task_ptr->mask_range.first, task_ptr->mask_range.second); - analyzer.set_use_char_model(!use_word_model); if (!analyzer.analyze()) { return 0; @@ -532,14 +527,8 @@ int asst::StageDropsImageAnalyzer::match_quantity(const Rect& roi, bool use_word #ifdef ASST_DEBUG cv::rectangle(m_image_draw, make_rect(result.rect), cv::Scalar(0, 0, 255)); - if (use_word_model) { - cv::putText(m_image_draw, result.text, cv::Point(result.rect.x, result.rect.y - 20), cv::FONT_HERSHEY_SIMPLEX, - 0.5, cv::Scalar(0, 0, 255), 2); - } - else { - cv::putText(m_image_draw, result.text, cv::Point(result.rect.x, result.rect.y - 5), cv::FONT_HERSHEY_SIMPLEX, - 0.5, cv::Scalar(0, 255, 0), 2); - } + cv::putText(m_image_draw, result.text, cv::Point(result.rect.x, result.rect.y - 5), cv::FONT_HERSHEY_SIMPLEX, 0.5, + cv::Scalar(0, 255, 0), 2); #endif std::string digit_str = result.text; diff --git a/src/MaaCore/Vision/Roguelike/StageDropsImageAnalyzer.h b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.h similarity index 94% rename from src/MaaCore/Vision/Roguelike/StageDropsImageAnalyzer.h rename to src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.h index 92c840470f..6c7d1ba1be 100644 --- a/src/MaaCore/Vision/Roguelike/StageDropsImageAnalyzer.h +++ b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.h @@ -1,6 +1,6 @@ #pragma once -#include "Vision/AbstractImageAnalyzer.h" #include "Config/Miscellaneous/StageDropsConfig.h" +#include "Vision/AbstractImageAnalyzer.h" namespace asst { @@ -27,7 +27,7 @@ namespace asst bool analyze_baseline(); bool analyze_drops(); - int match_quantity(const Rect& roi, bool use_word_model = false); + int match_quantity(const Rect& roi); StageDropType match_droptype(const Rect& roi); std::string match_item(const Rect& roi, StageDropType type, int index, int size); diff --git a/src/MaaCore/Vision/OcrImageAnalyzer.cpp b/src/MaaCore/Vision/OcrImageAnalyzer.cpp index dbb9f439d7..39927d042b 100644 --- a/src/MaaCore/Vision/OcrImageAnalyzer.cpp +++ b/src/MaaCore/Vision/OcrImageAnalyzer.cpp @@ -60,15 +60,17 @@ bool asst::OcrImageAnalyzer::analyze() m_roi = correct_rect(m_roi, m_image); - OcrPack* ocr_ptr = nullptr; - if (m_use_char_model) { - ocr_ptr = &CharOcr::get_instance(); - } - else { - ocr_ptr = &WordOcr::get_instance(); - } - m_ocr_result = ocr_ptr->recognize(m_image, m_roi, all_pred, m_without_det); - ocr_ptr = nullptr; + // OcrPack* ocr_ptr = nullptr; + // if (m_use_char_model) { + // ocr_ptr = &CharOcr::get_instance(); + // } + // else { + // ocr_ptr = &WordOcr::get_instance(); + // } + // m_ocr_result = ocr_ptr->recognize(m_image, m_roi, all_pred, m_without_det); + // ocr_ptr = nullptr; + + m_ocr_result = WordOcr::get_instance().recognize(m_image, m_roi, all_pred, m_without_det); // log.trace("ocr result", m_ocr_result); return !m_ocr_result.empty(); @@ -107,7 +109,6 @@ void asst::OcrImageAnalyzer::set_task_info(OcrTaskInfo task_info) noexcept m_full_match = task_info.full_match; m_replace = std::move(task_info.replace_map); m_use_cache = task_info.cache; - m_use_char_model = task_info.is_ascii; if (m_use_cache && !m_region_of_appeared.empty()) { m_roi = m_region_of_appeared; @@ -143,11 +144,6 @@ void asst::OcrImageAnalyzer::set_region_of_appeared(Rect region) noexcept } } -void asst::OcrImageAnalyzer::set_use_char_model(bool enable) noexcept -{ - m_use_char_model = enable; -} - void asst::OcrImageAnalyzer::set_pred(const TextRectProc& pred) { m_pred = pred; diff --git a/src/MaaCore/Vision/OcrImageAnalyzer.h b/src/MaaCore/Vision/OcrImageAnalyzer.h index ad817a3093..4a943bad65 100644 --- a/src/MaaCore/Vision/OcrImageAnalyzer.h +++ b/src/MaaCore/Vision/OcrImageAnalyzer.h @@ -32,7 +32,6 @@ namespace asst virtual void set_use_cache(bool is_use) noexcept; virtual void set_region_of_appeared(Rect region) noexcept; - virtual void set_use_char_model(bool enable) noexcept; void set_pred(const TextRectProc& pred); virtual const std::vector& get_result() const noexcept; @@ -49,6 +48,5 @@ namespace asst bool m_without_det = false; bool m_use_cache = false; Rect m_region_of_appeared; - bool m_use_char_model = false; }; }