diff --git a/src/MaaCore/MaaCore.vcxproj b/src/MaaCore/MaaCore.vcxproj
index aa1885f44a..2d882528bd 100644
--- a/src/MaaCore/MaaCore.vcxproj
+++ b/src/MaaCore/MaaCore.vcxproj
@@ -82,32 +82,32 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
@@ -235,32 +235,32 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
@@ -758,4 +758,4 @@
-
+
\ No newline at end of file
diff --git a/src/MaaCore/MaaCore.vcxproj.filters b/src/MaaCore/MaaCore.vcxproj.filters
index 57c9674c64..7482bf6f5e 100644
--- a/src/MaaCore/MaaCore.vcxproj.filters
+++ b/src/MaaCore/MaaCore.vcxproj.filters
@@ -141,25 +141,25 @@
源文件\Common
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
@@ -180,7 +180,7 @@
源文件\Vision\Miscellaneous
-
+
源文件\Vision\Miscellaneous
@@ -495,7 +495,7 @@
源文件\Task\Miscellaneous
-
+
源文件\Vision
@@ -588,7 +588,7 @@
源文件\Utils
-
+
源文件\Vision
@@ -617,25 +617,25 @@
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
-
+
源文件\Vision
@@ -656,7 +656,7 @@
源文件\Vision\Miscellaneous
-
+
源文件\Vision\Miscellaneous
@@ -914,7 +914,7 @@
源文件\Task\SSS
-
+
源文件\Vision
@@ -986,7 +986,7 @@
源文件\Resource\Miscellaneous
-
+
源文件\Vision
diff --git a/src/MaaCore/Task/BattleHelper.cpp b/src/MaaCore/Task/BattleHelper.cpp
index 92c3e10230..95b39d40ec 100644
--- a/src/MaaCore/Task/BattleHelper.cpp
+++ b/src/MaaCore/Task/BattleHelper.cpp
@@ -13,9 +13,9 @@
#include "Utils/NoWarningCV.h"
#include "Vision/Battle/BattleImageAnalyzer.h"
#include "Vision/Battle/BattleSkillReadyImageAnalyzer.h"
-#include "Vision/BestMatchImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/BestMatcher.h"
+#include "Vision/Matcher.h"
+#include "Vision/RegionOCRer.h"
using namespace asst::battle;
@@ -127,7 +127,7 @@ bool asst::BattleHelper::update_deployment(bool init, const cv::Mat& reusable)
std::vector unknown_opers;
for (auto& oper : cur_opers) {
- BestMatchImageAnalyzer avatar_analyzer(oper.avatar);
+ BestMatcher avatar_analyzer(oper.avatar);
if (oper.cooling) {
Log.trace("start matching cooling", oper.index);
static const double cooling_threshold = Task.get("BattleAvatarCoolingData")->templ_threshold;
@@ -370,7 +370,7 @@ bool asst::BattleHelper::use_skill(const Point& loc, bool keep_waiting)
bool asst::BattleHelper::check_pause_button(const cv::Mat& reusable)
{
cv::Mat image = reusable.empty() ? m_inst_helper.ctrler()->get_image() : reusable;
- MatchImageAnalyzer battle_flag_analyzer(image);
+ Matcher battle_flag_analyzer(image);
battle_flag_analyzer.set_task_info("BattleOfficiallyBegin");
bool ret = battle_flag_analyzer.analyze().has_value();
BattleImageAnalyzer battle_flag_analyzer_2(image);
@@ -622,7 +622,7 @@ std::string asst::BattleHelper::analyze_detail_page_oper_name(const cv::Mat& ima
const auto& replace_task = Task.get("CharsNameOcrReplace");
const auto& task = Task.get(oper_name_ocr_task_name());
- OcrWithPreprocessImageAnalyzer preproc_analyzer(image);
+ RegionOCRer preproc_analyzer(image);
preproc_analyzer.set_task_info(task);
preproc_analyzer.set_replace(replace_task->replace_map, replace_task->replace_full);
auto preproc_result_opt = preproc_analyzer.analyze();
@@ -632,7 +632,7 @@ std::string asst::BattleHelper::analyze_detail_page_oper_name(const cv::Mat& ima
}
Log.warn("ocr with preprocess got a invalid name, try to use detect model");
- OcrImageAnalyzer det_analyzer(image);
+ OCRer det_analyzer(image);
det_analyzer.set_task_info(task);
det_analyzer.set_replace(replace_task->replace_map, replace_task->replace_full);
auto det_result_opt = det_analyzer.analyze();
diff --git a/src/MaaCore/Task/Experiment/CombatRecordRecognitionTask.cpp b/src/MaaCore/Task/Experiment/CombatRecordRecognitionTask.cpp
index 1d1a127a7d..4f6de94d45 100644
--- a/src/MaaCore/Task/Experiment/CombatRecordRecognitionTask.cpp
+++ b/src/MaaCore/Task/Experiment/CombatRecordRecognitionTask.cpp
@@ -12,8 +12,8 @@
#include "Vision/Battle/BattleImageAnalyzer.h"
#include "Vision/Battle/BattleOperatorsImageAnalyzer.h"
#include "Vision/Battle/BattleSkillReadyImageAnalyzer.h"
-#include "Vision/BestMatchImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/BestMatcher.h"
+#include "Vision/RegionOCRer.h"
#include
#include
@@ -187,7 +187,7 @@ bool asst::CombatRecordRecognitionTask::analyze_stage()
cv::resize(frame, frame, cv::Size(), m_scale, m_scale, cv::INTER_AREA);
- OcrWithPreprocessImageAnalyzer stage_analyzer(frame);
+ RegionOCRer stage_analyzer(frame);
stage_analyzer.set_task_info(stage_name_task_ptr);
bool analyzed = stage_analyzer.analyze().has_value();
show_img(stage_analyzer);
@@ -263,7 +263,7 @@ bool asst::CombatRecordRecognitionTask::analyze_deployment()
auto avatar_task_ptr = Task.get("BattleAvatarDataForFormation");
for (const auto& [name, formation_avatar] : m_formation) {
- BestMatchImageAnalyzer best_match_analyzer(formation_avatar);
+ BestMatcher best_match_analyzer(formation_avatar);
best_match_analyzer.set_task_info(avatar_task_ptr);
std::unordered_set roles = { BattleData.get_role(name) };
@@ -769,7 +769,7 @@ void asst::CombatRecordRecognitionTask::ananlyze_deployment_names(ClipInfo& clip
if (!oper.name.empty()) {
continue;
}
- BestMatchImageAnalyzer avatar_analyzer(oper.avatar);
+ BestMatcher avatar_analyzer(oper.avatar);
static const double threshold = Task.get("BattleAvatarDataForVideo")->templ_threshold;
avatar_analyzer.set_threshold(threshold);
// static const double drone_threshold = Task.get("BattleDroneAvatarData")->templ_threshold;
@@ -854,7 +854,7 @@ std::string asst::CombatRecordRecognitionTask::analyze_detail_page_oper_name(con
{
const auto& replace_task = Task.get("CharsNameOcrReplace");
- OcrWithPreprocessImageAnalyzer preproc_analyzer(frame);
+ RegionOCRer preproc_analyzer(frame);
preproc_analyzer.set_task_info("BattleOperName");
preproc_analyzer.set_replace(replace_task->replace_map, replace_task->replace_full);
auto preproc_result_opt = preproc_analyzer.analyze();
@@ -864,7 +864,7 @@ std::string asst::CombatRecordRecognitionTask::analyze_detail_page_oper_name(con
}
Log.warn("ocr with preprocess got a invalid name, try to use detect model");
- OcrImageAnalyzer det_analyzer(frame);
+ OCRer det_analyzer(frame);
det_analyzer.set_task_info("BattleOperName");
det_analyzer.set_replace(replace_task->replace_map, replace_task->replace_full);
auto det_result_opt = det_analyzer.analyze();
@@ -877,7 +877,7 @@ std::string asst::CombatRecordRecognitionTask::analyze_detail_page_oper_name(con
return BattleData.is_name_invalid(det_name) ? std::string() : det_name;
}
-void asst::CombatRecordRecognitionTask::show_img(const asst::AbstractImageAnalyzer& analyzer)
+void asst::CombatRecordRecognitionTask::show_img(const asst::VisionHelper& analyzer)
{
#ifdef ASST_DEBUG
show_img(analyzer.get_draw());
diff --git a/src/MaaCore/Task/Experiment/CombatRecordRecognitionTask.h b/src/MaaCore/Task/Experiment/CombatRecordRecognitionTask.h
index 5e6ba7ef50..ac532ab149 100644
--- a/src/MaaCore/Task/Experiment/CombatRecordRecognitionTask.h
+++ b/src/MaaCore/Task/Experiment/CombatRecordRecognitionTask.h
@@ -15,7 +15,7 @@ namespace cv
namespace asst
{
- class AbstractImageAnalyzer;
+ class VisionHelper;
class CombatRecordRecognitionTask : public AbstractTask
{
@@ -95,7 +95,7 @@ namespace asst
json::value m_copilot_json;
int m_pre_action_costs = -1;
- void show_img(const AbstractImageAnalyzer& analyzer);
+ void show_img(const VisionHelper& analyzer);
void show_img(const cv::Mat& img);
#ifdef ASST_DEBUG
diff --git a/src/MaaCore/Task/Fight/DrGrandetTaskPlugin.cpp b/src/MaaCore/Task/Fight/DrGrandetTaskPlugin.cpp
index 4441c26e04..405052eb02 100644
--- a/src/MaaCore/Task/Fight/DrGrandetTaskPlugin.cpp
+++ b/src/MaaCore/Task/Fight/DrGrandetTaskPlugin.cpp
@@ -3,7 +3,7 @@
#include "Config/TaskData.h"
#include "Controller/Controller.h"
#include "Utils/Logger.hpp"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/OCRer.h"
#include
@@ -49,7 +49,7 @@ int asst::DrGrandetTaskPlugin::analyze_time_left()
{
LogTraceFunction;
- OcrImageAnalyzer analyzer(ctrler()->get_image());
+ OCRer analyzer(ctrler()->get_image());
analyzer.set_task_info("DrGrandetUseOriginiums");
analyzer.set_replace(Task.get("NumberOcrReplace")->replace_map);
// 这里是汉字和数字混合的,用不了单独的en模型
diff --git a/src/MaaCore/Task/Fight/StageNavigationTask.cpp b/src/MaaCore/Task/Fight/StageNavigationTask.cpp
index ea57f05512..9da8f1da58 100644
--- a/src/MaaCore/Task/Fight/StageNavigationTask.cpp
+++ b/src/MaaCore/Task/Fight/StageNavigationTask.cpp
@@ -6,7 +6,7 @@
#include "Controller/Controller.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/OCRer.h"
bool asst::StageNavigationTask::set_stage_name(const std::string& stage_name)
{
diff --git a/src/MaaCore/Task/Infrast/InfrastAbstractTask.cpp b/src/MaaCore/Task/Infrast/InfrastAbstractTask.cpp
index 24e67a651e..309c368708 100644
--- a/src/MaaCore/Task/Infrast/InfrastAbstractTask.cpp
+++ b/src/MaaCore/Task/Infrast/InfrastAbstractTask.cpp
@@ -12,9 +12,9 @@
#include "Utils/Ranges.hpp"
#include "Vision/Infrast/InfrastFacilityImageAnalyzer.h"
#include "Vision/Infrast/InfrastOperImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/OCRer.h"
+#include "Vision/RegionOCRer.h"
asst::InfrastAbstractTask::InfrastAbstractTask(const AsstCallback& callback, Assistant* inst,
std::string_view task_chain)
@@ -278,7 +278,7 @@ bool asst::InfrastAbstractTask::select_opers_review(infrast::CustomRoomConfig co
const auto& ocr_replace = Task.get("CharsNameOcrReplace");
for (const auto& oper : oper_analyzer_res) {
- OcrWithPreprocessImageAnalyzer name_analyzer;
+ RegionOCRer name_analyzer;
name_analyzer.set_replace(ocr_replace->replace_map, ocr_replace->replace_full);
name_analyzer.set_image(oper.name_img);
name_analyzer.set_bin_expansion(0);
@@ -334,7 +334,7 @@ bool asst::InfrastAbstractTask::select_custom_opers(std::vector& pa
const auto& ocr_replace = Task.get("CharsNameOcrReplace");
for (const auto& oper : oper_analyzer.get_result()) {
- OcrWithPreprocessImageAnalyzer name_analyzer;
+ RegionOCRer name_analyzer;
name_analyzer.set_replace(ocr_replace->replace_map, ocr_replace->replace_full);
name_analyzer.set_image(oper.name_img);
name_analyzer.set_bin_expansion(0);
@@ -391,7 +391,7 @@ void asst::InfrastAbstractTask::order_opers_selection(const std::vector page_result;
for (const auto& oper : oper_analyzer.get_result()) {
- OcrWithPreprocessImageAnalyzer name_analyzer;
+ RegionOCRer name_analyzer;
name_analyzer.set_replace(ocr_replace->replace_map, ocr_replace->replace_full);
name_analyzer.set_image(oper.name_img);
name_analyzer.set_bin_expansion(0);
diff --git a/src/MaaCore/Task/Infrast/InfrastDormTask.cpp b/src/MaaCore/Task/Infrast/InfrastDormTask.cpp
index 02b5d93935..e1e6533c32 100644
--- a/src/MaaCore/Task/Infrast/InfrastDormTask.cpp
+++ b/src/MaaCore/Task/Infrast/InfrastDormTask.cpp
@@ -7,9 +7,9 @@
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
#include "Vision/Infrast/InfrastOperImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/OCRer.h"
+#include "Vision/RegionOCRer.h"
asst::InfrastDormTask& asst::InfrastDormTask::set_notstationed_enabled(bool dorm_notstationed_enabled) noexcept
{
@@ -131,7 +131,7 @@ bool asst::InfrastDormTask::opers_choose(asst::infrast::CustomRoomConfig const&
if (m_dorm_trust_enabled && m_next_step != NextStep::Rest && oper.selected == false &&
oper.doing != infrast::Doing::Working && oper.doing != infrast::Doing::Resting) {
// 获得干员信赖值
- OcrWithPreprocessImageAnalyzer trust_analyzer(oper.name_img);
+ RegionOCRer trust_analyzer(oper.name_img);
if (!trust_analyzer.analyze()) {
Log.trace("ERROR:!trust_analyzer.analyze()");
break;
@@ -164,7 +164,7 @@ bool asst::InfrastDormTask::opers_choose(asst::infrast::CustomRoomConfig const&
}
// 获得干员所在设施
- OcrWithPreprocessImageAnalyzer facility_analyzer(oper.facility_img);
+ RegionOCRer facility_analyzer(oper.facility_img);
if (!facility_analyzer.analyze()) {
Log.trace("ERROR:!facility_analyzer.analyze()");
break;
diff --git a/src/MaaCore/Task/Infrast/InfrastMfgTask.cpp b/src/MaaCore/Task/Infrast/InfrastMfgTask.cpp
index a242113981..22e2979607 100644
--- a/src/MaaCore/Task/Infrast/InfrastMfgTask.cpp
+++ b/src/MaaCore/Task/Infrast/InfrastMfgTask.cpp
@@ -1,7 +1,7 @@
#include "InfrastMfgTask.h"
#include "Controller/Controller.h"
-#include "Vision/MatchImageAnalyzer.h"
+#include "Vision/Matcher.h"
bool asst::InfrastMfgTask::_run()
{
diff --git a/src/MaaCore/Task/Infrast/InfrastProductionTask.cpp b/src/MaaCore/Task/Infrast/InfrastProductionTask.cpp
index 487a879c5e..f1f17fb77c 100644
--- a/src/MaaCore/Task/Infrast/InfrastProductionTask.cpp
+++ b/src/MaaCore/Task/Infrast/InfrastProductionTask.cpp
@@ -11,11 +11,11 @@
#include "Status.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/HashImageAnalyzer.h"
+#include "Vision/Hasher.h"
#include "Vision/Infrast/InfrastOperImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/MultiMatchImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/MultiMatcher.h"
+#include "Vision/RegionOCRer.h"
asst::InfrastProductionTask& asst::InfrastProductionTask::set_uses_of_drone(std::string uses_of_drones) noexcept
{
@@ -159,7 +159,7 @@ bool asst::InfrastProductionTask::shift_facility_list()
/* 识别当前制造/贸易站有没有添加干员按钮,没有就不换班 */
const auto image = ctrler()->get_image();
- MatchImageAnalyzer add_analyzer(image);
+ Matcher add_analyzer(image);
const auto add_task_ptr = Task.get("InfrastAddOperator" + facility_name() + m_work_mode_name);
add_analyzer.set_task_info(add_task_ptr);
if (!add_analyzer.analyze()) {
@@ -173,7 +173,7 @@ bool asst::InfrastProductionTask::shift_facility_list()
}
/* 识别当前正在造什么 */
- MatchImageAnalyzer product_analyzer(image);
+ Matcher product_analyzer(image);
auto& all_products = InfrastData.get_facility_info(facility_name()).products;
std::string cur_product = all_products.at(0);
double max_score = 0;
@@ -189,7 +189,7 @@ bool asst::InfrastProductionTask::shift_facility_list()
}
set_product(cur_product);
- MultiMatchImageAnalyzer locked_analyzer(image);
+ MultiMatcher locked_analyzer(image);
locked_analyzer.set_task_info("InfrastOperLocked" + facility_name());
if (locked_analyzer.analyze()) {
m_cur_num_of_locked_opers = static_cast(locked_analyzer.get_result().size());
@@ -336,7 +336,7 @@ size_t asst::InfrastProductionTask::opers_detect()
return false;
}
// 有可能是同一个干员,比一下hash
- int dist = HashImageAnalyzer::hamming(cur_oper.face_hash, oper.face_hash);
+ int dist = Hasher::hamming(cur_oper.face_hash, oper.face_hash);
Log.debug("opers_detect hash dist |", dist);
return dist < face_hash_thres;
});
@@ -502,7 +502,7 @@ bool asst::InfrastProductionTask::optimal_calc()
hash_matched = true;
}
else {
- OcrWithPreprocessImageAnalyzer name_analyzer(find_iter->name_img);
+ RegionOCRer name_analyzer(find_iter->name_img);
name_analyzer.set_replace(Task.get("CharsNameOcrReplace")->replace_map,
Task.get("CharsNameOcrReplace")->replace_full);
Log.trace("Analyze name filter");
@@ -630,7 +630,7 @@ bool asst::InfrastProductionTask::opers_choose()
return true;
}
else {
- OcrWithPreprocessImageAnalyzer name_analyzer(lhs.name_img);
+ RegionOCRer name_analyzer(lhs.name_img);
name_analyzer.set_replace(Task.get("CharsNameOcrReplace")->replace_map,
Task.get("CharsNameOcrReplace")->replace_full);
Log.trace("Analyze name filter");
@@ -662,7 +662,7 @@ bool asst::InfrastProductionTask::opers_choose()
}
{
auto avlb_iter = ranges::find_if(m_all_available_opers, [&](const infrast::Oper& lhs) -> bool {
- int dist = HashImageAnalyzer::hamming(lhs.face_hash, find_iter->face_hash);
+ int dist = Hasher::hamming(lhs.face_hash, find_iter->face_hash);
Log.debug("opers_choose | face hash dist", dist);
return dist < face_hash_thres;
});
@@ -742,7 +742,7 @@ bool asst::InfrastProductionTask::facility_list_detect()
m_facility_list_tabs.clear();
const auto image = ctrler()->get_image();
- MultiMatchImageAnalyzer mm_analyzer(image);
+ MultiMatcher mm_analyzer(image);
mm_analyzer.set_task_info("InfrastFacilityListTab" + facility_name());
diff --git a/src/MaaCore/Task/Infrast/InfrastReceptionTask.cpp b/src/MaaCore/Task/Infrast/InfrastReceptionTask.cpp
index f8e7572b8c..bcea48be5f 100644
--- a/src/MaaCore/Task/Infrast/InfrastReceptionTask.cpp
+++ b/src/MaaCore/Task/Infrast/InfrastReceptionTask.cpp
@@ -7,8 +7,8 @@
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
#include "Vision/Infrast/InfrastClueVacancyImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/MultiMatchImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/MultiMatcher.h"
bool asst::InfrastReceptionTask::_run()
{
@@ -119,7 +119,7 @@ bool asst::InfrastReceptionTask::proc_clue_vacancy()
// 识别右边列表中的线索,然后用最底下的那个(一般都是剩余时间最短的)
// swipe_to_the_bottom_of_clue_list_on_the_right();
image = ctrler()->get_image();
- MultiMatchImageAnalyzer clue_analyzer(image);
+ MultiMatcher clue_analyzer(image);
clue_analyzer.set_task_info("InfrastClue");
auto clue_result_opt = clue_analyzer.analyze();
@@ -162,7 +162,7 @@ bool asst::InfrastReceptionTask::shift()
}
const auto image = ctrler()->get_image();
- MatchImageAnalyzer add_analyzer(image);
+ Matcher add_analyzer(image);
const auto raw_task_ptr = Task.get("InfrastAddOperator" + facility_name() + m_work_mode_name);
switch (raw_task_ptr->algorithm) {
diff --git a/src/MaaCore/Task/Miscellaneous/AutoRecruitTask.cpp b/src/MaaCore/Task/Miscellaneous/AutoRecruitTask.cpp
index 65a6c06174..e2f63980a4 100644
--- a/src/MaaCore/Task/Miscellaneous/AutoRecruitTask.cpp
+++ b/src/MaaCore/Task/Miscellaneous/AutoRecruitTask.cpp
@@ -8,8 +8,8 @@
#include "Task/ReportDataTask.h"
#include "Utils/Logger.hpp"
#include "Vision/Miscellaneous/RecruitImageAnalyzer.h"
-#include "Vision/MultiMatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/MultiMatcher.h"
+#include "Vision/OCRer.h"
#include "Utils/Ranges.hpp"
#include
@@ -252,7 +252,7 @@ bool asst::AutoRecruitTask::_run()
std::vector asst::AutoRecruitTask::start_recruit_analyze(const cv::Mat& image)
{
- OcrImageAnalyzer start_analyzer(image);
+ OCRer start_analyzer(image);
start_analyzer.set_task_info("StartRecruit");
if (!start_analyzer.analyze()) return {};
return start_analyzer.get_result();
@@ -591,7 +591,7 @@ bool asst::AutoRecruitTask::check_timer(int minutes_expected)
const auto replace_map = Task.get("NumberOcrReplace")->replace_map;
{
- OcrImageAnalyzer hour_ocr(image);
+ OCRer hour_ocr(image);
hour_ocr.set_task_info("RecruitTimerH");
hour_ocr.set_replace(replace_map);
if (!hour_ocr.analyze()) return false;
@@ -601,7 +601,7 @@ bool asst::AutoRecruitTask::check_timer(int minutes_expected)
if (minutes_expected % 60 == 0) return true; // minute counter stays untouched
{
- OcrImageAnalyzer minute_ocr(image);
+ OCRer minute_ocr(image);
minute_ocr.set_task_info("RecruitTimerM");
minute_ocr.set_replace(replace_map);
if (!minute_ocr.analyze()) return false;
@@ -641,7 +641,7 @@ bool asst::AutoRecruitTask::hire_all(const cv::Mat& image)
LogTraceFunction;
// mark slots with *Hire* button clean (regardless of whether hiring will success)
{
- MultiMatchImageAnalyzer hire_searcher(image);
+ MultiMatcher hire_searcher(image);
hire_searcher.set_task_info("RecruitFinish");
hire_searcher.analyze();
for (const MatchRect& r : hire_searcher.get_result()) {
diff --git a/src/MaaCore/Task/Miscellaneous/BattleFormationTask.cpp b/src/MaaCore/Task/Miscellaneous/BattleFormationTask.cpp
index 9a15b8e953..b4c1423a8b 100644
--- a/src/MaaCore/Task/Miscellaneous/BattleFormationTask.cpp
+++ b/src/MaaCore/Task/Miscellaneous/BattleFormationTask.cpp
@@ -9,7 +9,7 @@
#include "Controller/Controller.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
+#include "Vision/TemplDetOCRer.h"
void asst::BattleFormationTask::append_additional_formation(AdditionalFormation formation)
{
@@ -133,12 +133,12 @@ std::vector asst::BattleFormationTask::analyzer_opers()
auto image = ctrler()->get_image();
const auto& ocr_replace = Task.get("CharsNameOcrReplace");
- OcrWithFlagTemplImageAnalyzer name_analyzer(image);
+ TemplDetOCRer name_analyzer(image);
name_analyzer.set_task_info("BattleQuickFormation-OperNameFlag", "BattleQuickFormationOCR");
name_analyzer.set_replace(ocr_replace->replace_map, ocr_replace->replace_full);
name_analyzer.analyze();
- OcrWithFlagTemplImageAnalyzer special_focus_analyzer(image);
+ TemplDetOCRer special_focus_analyzer(image);
special_focus_analyzer.set_task_info("BattleQuickFormation-OperNameFlag-SpecialFocus", "BattleQuickFormationOCR");
special_focus_analyzer.set_replace(ocr_replace->replace_map, ocr_replace->replace_full);
special_focus_analyzer.analyze();
diff --git a/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp b/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp
index 301bd5a0c4..a6e69d5d87 100644
--- a/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp
+++ b/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp
@@ -18,8 +18,8 @@
#include "Utils/Logger.hpp"
#include "Vision/Battle/BattleImageAnalyzer.h"
#include "Vision/Battle/BattleSkillReadyImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/RegionOCRer.h"
using namespace asst::battle;
using namespace asst::battle::copilot;
diff --git a/src/MaaCore/Task/Miscellaneous/CreditShoppingTask.cpp b/src/MaaCore/Task/Miscellaneous/CreditShoppingTask.cpp
index 087b269cdf..b9a8eef2b0 100644
--- a/src/MaaCore/Task/Miscellaneous/CreditShoppingTask.cpp
+++ b/src/MaaCore/Task/Miscellaneous/CreditShoppingTask.cpp
@@ -7,9 +7,9 @@
#include "Controller/Controller.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/MatchImageAnalyzer.h"
+#include "Vision/Matcher.h"
#include "Vision/Miscellaneous/CreditShopImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/OCRer.h"
void asst::CreditShoppingTask::set_black_list(std::vector black_list)
{
@@ -33,7 +33,7 @@ asst::CreditShoppingTask& asst::CreditShoppingTask::set_force_shopping_if_credit
int asst::CreditShoppingTask::credit_ocr()
{
cv::Mat credit_image = ctrler()->get_image();
- OcrImageAnalyzer credit_analyzer(credit_image);
+ OCRer credit_analyzer(credit_image);
credit_analyzer.set_task_info("CreditShop-CreditOcr");
credit_analyzer.set_replace(Task.get("NumberOcrReplace")->replace_map);
diff --git a/src/MaaCore/Task/Miscellaneous/OperBoxRecognitionTask.cpp b/src/MaaCore/Task/Miscellaneous/OperBoxRecognitionTask.cpp
index c522a98062..b5d1b38538 100644
--- a/src/MaaCore/Task/Miscellaneous/OperBoxRecognitionTask.cpp
+++ b/src/MaaCore/Task/Miscellaneous/OperBoxRecognitionTask.cpp
@@ -8,7 +8,7 @@
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
#include "Vision/Miscellaneous/OperBoxImageAnalyzer.h"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
+#include "Vision/TemplDetOCRer.h"
#include
bool asst::OperBoxRecognitionTask::_run()
diff --git a/src/MaaCore/Task/ProcessTask.cpp b/src/MaaCore/Task/ProcessTask.cpp
index 199573e8bd..5fe9718528 100644
--- a/src/MaaCore/Task/ProcessTask.cpp
+++ b/src/MaaCore/Task/ProcessTask.cpp
@@ -11,7 +11,7 @@
#include "Controller/Controller.h"
#include "Status.h"
#include "Utils/Logger.hpp"
-#include "Vision/Miscellaneous/ProcessTaskImageAnalyzer.h"
+#include "Vision/Miscellaneous/PipelineAnalyzer.h"
using namespace asst;
@@ -120,7 +120,7 @@ bool ProcessTask::_run()
else {
cv::Mat image = m_reusable.empty() ? ctrler()->get_image() : m_reusable;
m_reusable = cv::Mat();
- ProcessTaskImageAnalyzer analyzer(image, Rect(), m_inst);
+ PipelineAnalyzer analyzer(image, Rect(), m_inst);
analyzer.set_tasks(m_cur_task_name_list);
auto res_opt = analyzer.analyze();
diff --git a/src/MaaCore/Task/Reclamation/ReclamationBattlePlugin.cpp b/src/MaaCore/Task/Reclamation/ReclamationBattlePlugin.cpp
index 1068621e31..b38b237541 100644
--- a/src/MaaCore/Task/Reclamation/ReclamationBattlePlugin.cpp
+++ b/src/MaaCore/Task/Reclamation/ReclamationBattlePlugin.cpp
@@ -9,8 +9,8 @@
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
#include "Vision/Battle/BattleSkillReadyImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/OCRer.h"
using namespace asst;
@@ -77,12 +77,12 @@ bool asst::ReclamationBattlePlugin::quit_action()
const auto img = ctrler()->get_image();
bool check1 = check_in_battle(img, false);
- OcrImageAnalyzer confirmAnalyzer(img);
+ OCRer confirmAnalyzer(img);
confirmAnalyzer.set_task_info("Reclamation@ExitLevelConfirm");
bool check2 = confirmAnalyzer.analyze().has_value();
// 出现Loading转一会儿就结算了,没结算还有error_next
- OcrImageAnalyzer loadingAnalyzer(img);
+ OCRer loadingAnalyzer(img);
loadingAnalyzer.set_task_info("LoadingText");
bool check3 = loadingAnalyzer.analyze().has_value();
@@ -144,7 +144,7 @@ bool asst::ReclamationBattlePlugin::communicate_with_aux(
// sleep(use_oper_task_ptr->pre_delay);
//
// image = ctrler()->get_image();
- // OcrImageAnalyzer npcNameAnalyzer(image);
+ // OCRer npcNameAnalyzer(image);
// npcNameAnalyzer.set_task_info("Reclamation@Liaison");
// npcNameAnalyzer.set_required({});
// if (!npcNameAnalyzer.analyze()) {
@@ -189,7 +189,7 @@ bool asst::ReclamationBattlePlugin::do_dialog_procedure(const std::vectorget_image();
- OcrImageAnalyzer dialogAnalyzer(image);
+ OCRer dialogAnalyzer(image);
dialogAnalyzer.set_task_info("Reclamation@BalckMarketDialogOption");
dialogAnalyzer.set_required({ step });
if (!dialogAnalyzer.analyze()) {
diff --git a/src/MaaCore/Task/Reclamation/ReclamationConclusionReportPlugin.cpp b/src/MaaCore/Task/Reclamation/ReclamationConclusionReportPlugin.cpp
index 1c83611f09..16d6cc75d0 100644
--- a/src/MaaCore/Task/Reclamation/ReclamationConclusionReportPlugin.cpp
+++ b/src/MaaCore/Task/Reclamation/ReclamationConclusionReportPlugin.cpp
@@ -7,8 +7,8 @@
#include "Status.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/OCRer.h"
bool asst::ReclamationConclusionReportPlugin::verify(AsstMsg msg, const json::value& details) const
{
@@ -35,7 +35,7 @@ bool asst::ReclamationConclusionReportPlugin::_run()
bool asst::ReclamationConclusionReportPlugin::check_page_valid(const cv::Mat& image)
{
- MatchImageAnalyzer pageAnalyzer(image);
+ Matcher pageAnalyzer(image);
pageAnalyzer.set_task_info("Reclamation@GiveupSkipConfirm");
return pageAnalyzer.analyze().has_value();
}
@@ -51,12 +51,12 @@ void asst::ReclamationConclusionReportPlugin::analyze(const cv::Mat& image)
int asst::ReclamationConclusionReportPlugin::analyze_badges(const cv::Mat& image)
{
- MatchImageAnalyzer badgeIconAnalyzer(image);
+ Matcher badgeIconAnalyzer(image);
badgeIconAnalyzer.set_task_info("Reclamation@ConclusionReportBadgeIcon");
if (!badgeIconAnalyzer.analyze()) return -1;
const auto& iconRect = badgeIconAnalyzer.get_result();
- OcrImageAnalyzer badgeCntAnalyzer(image);
+ OCRer badgeCntAnalyzer(image);
badgeCntAnalyzer.set_task_info("NumberOcrReplace");
Rect roi = Task.get("Reclamation@ReportBadgesOcr")->roi;
int newX = iconRect.rect.x + iconRect.rect.width;
@@ -75,7 +75,7 @@ int asst::ReclamationConclusionReportPlugin::analyze_badges(const cv::Mat& image
int asst::ReclamationConclusionReportPlugin::analyze_construction_points(const cv::Mat& image)
{
- OcrImageAnalyzer consAnalyzer(image);
+ OCRer consAnalyzer(image);
consAnalyzer.set_task_info("NumberOcrReplace");
consAnalyzer.set_roi(Task.get("Reclamation@ReportConstructPointsOcr")->roi);
if (!consAnalyzer.analyze()) return -1;
diff --git a/src/MaaCore/Task/Reclamation/ReclamationControlTask.cpp b/src/MaaCore/Task/Reclamation/ReclamationControlTask.cpp
index 0977495309..2f1089e673 100644
--- a/src/MaaCore/Task/Reclamation/ReclamationControlTask.cpp
+++ b/src/MaaCore/Task/Reclamation/ReclamationControlTask.cpp
@@ -4,8 +4,8 @@
#include "Controller/Controller.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/OcrImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/OCRer.h"
+#include "Vision/RegionOCRer.h"
#include "ReclamationBattlePlugin.h"
diff --git a/src/MaaCore/Task/Roguelike/RoguelikeBattleTaskPlugin.cpp b/src/MaaCore/Task/Roguelike/RoguelikeBattleTaskPlugin.cpp
index be94dd0b7b..864a71e9c2 100644
--- a/src/MaaCore/Task/Roguelike/RoguelikeBattleTaskPlugin.cpp
+++ b/src/MaaCore/Task/Roguelike/RoguelikeBattleTaskPlugin.cpp
@@ -19,8 +19,8 @@
#include "Utils/Logger.hpp"
#include "Vision/Battle/BattleImageAnalyzer.h"
#include "Vision/Battle/BattleSkillReadyImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/RegionOCRer.h"
using namespace asst::battle;
using namespace asst::battle::roguelike;
@@ -124,7 +124,7 @@ bool asst::RoguelikeBattleTaskPlugin::calc_stage_info()
if (need_exit()) {
return false;
}
- OcrWithPreprocessImageAnalyzer name_analyzer(ctrler()->get_image());
+ RegionOCRer name_analyzer(ctrler()->get_image());
name_analyzer.set_task_info(stage_name_task_ptr);
if (!name_analyzer.analyze()) {
continue;
diff --git a/src/MaaCore/Task/Roguelike/RoguelikeCustomStartTaskPlugin.cpp b/src/MaaCore/Task/Roguelike/RoguelikeCustomStartTaskPlugin.cpp
index cfe92d40d8..7ea53b44f3 100644
--- a/src/MaaCore/Task/Roguelike/RoguelikeCustomStartTaskPlugin.cpp
+++ b/src/MaaCore/Task/Roguelike/RoguelikeCustomStartTaskPlugin.cpp
@@ -6,7 +6,7 @@
#include "Status.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/OCRer.h"
bool asst::RoguelikeCustomStartTaskPlugin::verify(AsstMsg msg, const json::value& details) const
{
@@ -79,7 +79,7 @@ bool asst::RoguelikeCustomStartTaskPlugin::hijack_squad()
constexpr size_t SwipeTimes = 7;
for (size_t i = 0; i != SwipeTimes; ++i) {
auto image = ctrler()->get_image();
- OcrImageAnalyzer analyzer(image);
+ OCRer analyzer(image);
analyzer.set_task_info("RoguelikeCustom-HijackSquad");
analyzer.set_required({ m_customs[RoguelikeCustomType::Squad] });
@@ -99,7 +99,7 @@ bool asst::RoguelikeCustomStartTaskPlugin::hijack_squad()
bool asst::RoguelikeCustomStartTaskPlugin::hijack_roles()
{
auto image = ctrler()->get_image();
- OcrImageAnalyzer analyzer(image);
+ OCRer analyzer(image);
analyzer.set_task_info("RoguelikeCustom-HijackRoles");
analyzer.set_required({ m_customs[RoguelikeCustomType::Roles] });
@@ -130,7 +130,7 @@ bool asst::RoguelikeCustomStartTaskPlugin::hijack_core_char()
const std::string& role_ocr_name = role_iter->second;
Log.info("role", role_ocr_name);
auto image = ctrler()->get_image();
- OcrImageAnalyzer analyzer(image);
+ OCRer analyzer(image);
analyzer.set_task_info("RoguelikeCustom-HijackCoChar");
analyzer.set_required({ role_ocr_name });
if (!analyzer.analyze()) {
diff --git a/src/MaaCore/Task/Roguelike/RoguelikeRecruitTaskPlugin.cpp b/src/MaaCore/Task/Roguelike/RoguelikeRecruitTaskPlugin.cpp
index 1f28883223..139d86c12d 100644
--- a/src/MaaCore/Task/Roguelike/RoguelikeRecruitTaskPlugin.cpp
+++ b/src/MaaCore/Task/Roguelike/RoguelikeRecruitTaskPlugin.cpp
@@ -8,8 +8,8 @@
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
#include "Utils/NoWarningCV.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/OCRer.h"
#include "Vision/Roguelike/RoguelikeRecruitImageAnalyzer.h"
#include "Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.h"
@@ -163,7 +163,7 @@ bool asst::RoguelikeRecruitTaskPlugin::_run()
bool temp_recruit_exist = false; // 检测是否存在临时招募
auto image = ctrler()->get_image();
- MatchImageAnalyzer temp_recruit_analyzer(image);
+ Matcher temp_recruit_analyzer(image);
temp_recruit_analyzer.set_task_info("Roguelike@TempRecruitFlag");
temp_recruit_exist = temp_recruit_analyzer.analyze().has_value();
Log.trace(__FUNCTION__, "temp_recruit_exist", temp_recruit_exist);
diff --git a/src/MaaCore/Task/Roguelike/RoguelikeShoppingTaskPlugin.cpp b/src/MaaCore/Task/Roguelike/RoguelikeShoppingTaskPlugin.cpp
index 63b908601d..0f21c490be 100644
--- a/src/MaaCore/Task/Roguelike/RoguelikeShoppingTaskPlugin.cpp
+++ b/src/MaaCore/Task/Roguelike/RoguelikeShoppingTaskPlugin.cpp
@@ -6,7 +6,7 @@
#include "Status.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
+#include "Vision/TemplDetOCRer.h"
bool asst::RoguelikeShoppingTaskPlugin::verify(AsstMsg msg, const json::value& details) const
{
@@ -37,7 +37,7 @@ bool asst::RoguelikeShoppingTaskPlugin::_run()
{
LogTraceFunction;
- OcrWithFlagTemplImageAnalyzer analyzer;
+ TemplDetOCRer analyzer;
analyzer.set_task_info("RoguelikeTraderShopping", "RoguelikeTraderShoppingOcr");
analyzer.set_image(ctrler()->get_image());
diff --git a/src/MaaCore/Task/Roguelike/RoguelikeStageEncounterTaskPlugin.cpp b/src/MaaCore/Task/Roguelike/RoguelikeStageEncounterTaskPlugin.cpp
index 3c6cb17246..448136eed5 100644
--- a/src/MaaCore/Task/Roguelike/RoguelikeStageEncounterTaskPlugin.cpp
+++ b/src/MaaCore/Task/Roguelike/RoguelikeStageEncounterTaskPlugin.cpp
@@ -7,7 +7,7 @@
#include "Task/ProcessTask.h"
#include "Utils/ImageIo.hpp"
#include "Utils/Logger.hpp"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/RegionOCRer.h"
bool asst::RoguelikeStageEncounterTaskPlugin::verify(AsstMsg msg, const json::value& details) const
{
@@ -59,7 +59,7 @@ bool asst::RoguelikeStageEncounterTaskPlugin::_run()
cv::threshold(grey_image, black_image, 80, 255, 0); // 要做个二值化,不然识别效果很差
cv::cvtColor(black_image, image, cv::COLOR_GRAY2RGB);
- OcrWithPreprocessImageAnalyzer name_analyzer(image);
+ RegionOCRer name_analyzer(image);
name_analyzer.set_task_info(event_name_task_ptr);
event_name_task_ptr->roi.y += 5; // 因文本纵向位置不固定,这里用一个滑动窗进行ocr
if (!name_analyzer.analyze()) {
diff --git a/src/MaaCore/Task/SSS/SSSDropRewardsTaskPlugin.cpp b/src/MaaCore/Task/SSS/SSSDropRewardsTaskPlugin.cpp
index 71198ec483..f665356e02 100644
--- a/src/MaaCore/Task/SSS/SSSDropRewardsTaskPlugin.cpp
+++ b/src/MaaCore/Task/SSS/SSSDropRewardsTaskPlugin.cpp
@@ -7,8 +7,8 @@
#include "Task/ProcessTask.h"
#include "Task/SSS/SSSBattleProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/OcrImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/OCRer.h"
+#include "Vision/RegionOCRer.h"
bool asst::SSSDropRewardsTaskPlugin::verify(AsstMsg msg, const json::value& details) const
{
@@ -25,7 +25,7 @@ bool asst::SSSDropRewardsTaskPlugin::_run()
using namespace battle;
LogTraceFunction;
- OcrImageAnalyzer analyzer(ctrler()->get_image());
+ OCRer analyzer(ctrler()->get_image());
analyzer.set_task_info("SSSDropRecruitmentOCR");
if (!analyzer.analyze()) {
Log.error(__FUNCTION__, "OCR failed to analyze");
diff --git a/src/MaaCore/Task/SSS/SSSStageManagerTask.cpp b/src/MaaCore/Task/SSS/SSSStageManagerTask.cpp
index c79380a2ec..a2b669f624 100644
--- a/src/MaaCore/Task/SSS/SSSStageManagerTask.cpp
+++ b/src/MaaCore/Task/SSS/SSSStageManagerTask.cpp
@@ -6,8 +6,8 @@
#include "Task/ProcessTask.h"
#include "Task/SSS/SSSBattleProcessTask.h"
#include "Utils/Logger.hpp"
-#include "Vision/OcrImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/OCRer.h"
+#include "Vision/RegionOCRer.h"
bool asst::SSSStageManagerTask::_run()
{
@@ -71,7 +71,7 @@ std::optional asst::SSSStageManagerTask::analyze_stage()
{
LogTraceFunction;
- OcrWithPreprocessImageAnalyzer analyzer(ctrler()->get_image());
+ RegionOCRer analyzer(ctrler()->get_image());
analyzer.set_task_info("SSSStageNameOCR");
if (!analyzer.analyze()) {
return std::nullopt;
diff --git a/src/MaaCore/Vision/Battle/BattleDeployDirectionImageAnalyzer.h b/src/MaaCore/Vision/Battle/BattleDeployDirectionImageAnalyzer.h
index 9dc028f1eb..a3fe1563cf 100644
--- a/src/MaaCore/Vision/Battle/BattleDeployDirectionImageAnalyzer.h
+++ b/src/MaaCore/Vision/Battle/BattleDeployDirectionImageAnalyzer.h
@@ -1,17 +1,17 @@
#pragma once
-#include "Vision/OnnxRuntimeImageAnalyzer.h"
+#include "Vision/OnnxHelper.h"
namespace asst
{
- class BattleDeployDirectionImageAnalyzer final : public OnnxRuntimeImageAnalyzer
+ class BattleDeployDirectionImageAnalyzer final : public OnnxHelper
{
public:
static constexpr size_t ClassificationSize = 4;
using RawResults = std::array;
public:
- using OnnxRuntimeImageAnalyzer::OnnxRuntimeImageAnalyzer;
+ using OnnxHelper::OnnxHelper;
virtual ~BattleDeployDirectionImageAnalyzer() override = default;
void set_base_point(const Point& pt);
diff --git a/src/MaaCore/Vision/Battle/BattleFormationImageAnalyzer.cpp b/src/MaaCore/Vision/Battle/BattleFormationImageAnalyzer.cpp
index ca008ddc20..d01f8b8a74 100644
--- a/src/MaaCore/Vision/Battle/BattleFormationImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Battle/BattleFormationImageAnalyzer.cpp
@@ -4,21 +4,21 @@
#include "Config/TaskData.h"
#include "Utils/Logger.hpp"
#include "Utils/NoWarningCV.h"
-#include "Vision/Miscellaneous/ProcessTaskImageAnalyzer.h"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
+#include "Vision/Miscellaneous/PipelineAnalyzer.h"
+#include "Vision/TemplDetOCRer.h"
bool asst::BattleFormationImageAnalyzer::analyze()
{
LogTraceFunction;
m_result.clear();
- ProcessTaskImageAnalyzer start_button_analyzer(m_image);
+ PipelineAnalyzer start_button_analyzer(m_image);
start_button_analyzer.set_tasks(Task.get("BattleStartAll")->next);
if (!start_button_analyzer.analyze()) {
return false;
}
- OcrWithFlagTemplImageAnalyzer oper_names_analyzer(m_image);
+ TemplDetOCRer oper_names_analyzer(m_image);
oper_names_analyzer.set_task_info("BattleFormationOCRNameFlag", "BattleFormationOperNames");
oper_names_analyzer.set_bin_expansion(3);
if (!oper_names_analyzer.analyze()) {
diff --git a/src/MaaCore/Vision/Battle/BattleFormationImageAnalyzer.h b/src/MaaCore/Vision/Battle/BattleFormationImageAnalyzer.h
index 094c1a9f59..6020785dda 100644
--- a/src/MaaCore/Vision/Battle/BattleFormationImageAnalyzer.h
+++ b/src/MaaCore/Vision/Battle/BattleFormationImageAnalyzer.h
@@ -1,13 +1,13 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
namespace asst
{
- class BattleFormationImageAnalyzer : public AbstractImageAnalyzer
+ class BattleFormationImageAnalyzer : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~BattleFormationImageAnalyzer() override = default;
bool analyze();
diff --git a/src/MaaCore/Vision/Battle/BattleImageAnalyzer.cpp b/src/MaaCore/Vision/Battle/BattleImageAnalyzer.cpp
index a34ce0c548..6b87a9c455 100644
--- a/src/MaaCore/Vision/Battle/BattleImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Battle/BattleImageAnalyzer.cpp
@@ -8,11 +8,11 @@
#include "Config/TaskData.h"
#include "Config/TemplResource.h"
#include "Utils/Logger.hpp"
-#include "Vision/BestMatchImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/MultiMatchImageAnalyzer.h"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/BestMatcher.h"
+#include "Vision/Matcher.h"
+#include "Vision/MultiMatcher.h"
+#include "Vision/TemplDetOCRer.h"
+#include "Vision/RegionOCRer.h"
bool asst::BattleImageAnalyzer::set_target(int target)
{
@@ -122,7 +122,7 @@ void asst::BattleImageAnalyzer::sort_opers_by_cost()
bool asst::BattleImageAnalyzer::opers_analyze()
{
- MultiMatchImageAnalyzer flags_analyzer(m_image);
+ MultiMatcher flags_analyzer(m_image);
const auto& flag_task_ptr = Task.get("BattleOpersFlag");
flags_analyzer.set_task_info(flag_task_ptr);
#ifndef ASST_DEBUG
@@ -209,7 +209,7 @@ asst::battle::Role asst::BattleImageAnalyzer::oper_role_analyze(const Rect& roi)
static const std::string TaskName = "BattleOperRole";
static const std::string Ext = ".png";
- BestMatchImageAnalyzer role_analyzer(m_image);
+ BestMatcher role_analyzer(m_image);
#ifndef ASST_DEBUG
role_analyzer.set_log_tracing(false);
#endif // !ASST_DEBUG
@@ -331,7 +331,7 @@ bool asst::BattleImageAnalyzer::hp_flag_analyze()
{
// 识别 HP 的那个蓝白色图标
auto flag_task_ptr = Task.get("BattleHpFlag");
- MatchImageAnalyzer flag_analyzer(m_image);
+ Matcher flag_analyzer(m_image);
flag_analyzer.set_task_info(flag_task_ptr);
if (!flag_analyzer.analyze()) {
// 漏怪的时候,那个图标会变成红色的,所以多识别一次
@@ -346,14 +346,14 @@ bool asst::BattleImageAnalyzer::hp_flag_analyze()
bool asst::BattleImageAnalyzer::kills_flag_analyze()
{
- MatchImageAnalyzer flag_analyzer(m_image);
+ Matcher flag_analyzer(m_image);
flag_analyzer.set_task_info("BattleKillsFlag");
return flag_analyzer.analyze().has_value();
}
bool asst::BattleImageAnalyzer::kills_analyze()
{
- OcrWithFlagTemplImageAnalyzer kills_analyzer(m_image);
+ TemplDetOCRer kills_analyzer(m_image);
kills_analyzer.set_task_info("BattleKillsFlag", "BattleKills");
kills_analyzer.set_replace(Task.get("NumberOcrReplace")->replace_map);
@@ -418,7 +418,7 @@ bool asst::BattleImageAnalyzer::kills_analyze()
bool asst::BattleImageAnalyzer::cost_analyze()
{
- OcrWithPreprocessImageAnalyzer cost_analyzer(m_image);
+ RegionOCRer cost_analyzer(m_image);
cost_analyzer.set_task_info("BattleCostData");
cost_analyzer.set_replace(Task.get("NumberOcrReplace")->replace_map);
diff --git a/src/MaaCore/Vision/Battle/BattleImageAnalyzer.h b/src/MaaCore/Vision/Battle/BattleImageAnalyzer.h
index f8f7d36e0e..7bca839a43 100644
--- a/src/MaaCore/Vision/Battle/BattleImageAnalyzer.h
+++ b/src/MaaCore/Vision/Battle/BattleImageAnalyzer.h
@@ -1,11 +1,11 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
#include "Common/AsstBattleDef.h"
namespace asst
{
- class BattleImageAnalyzer : public AbstractImageAnalyzer
+ class BattleImageAnalyzer : public VisionHelper
{
public:
enum Target // 需要识别的目标
@@ -18,7 +18,7 @@ namespace asst
};
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~BattleImageAnalyzer() override = default;
bool set_target(int target);
diff --git a/src/MaaCore/Vision/Battle/BattleOperatorsImageAnalyzer.h b/src/MaaCore/Vision/Battle/BattleOperatorsImageAnalyzer.h
index 194da0c381..bb7f25860e 100644
--- a/src/MaaCore/Vision/Battle/BattleOperatorsImageAnalyzer.h
+++ b/src/MaaCore/Vision/Battle/BattleOperatorsImageAnalyzer.h
@@ -1,11 +1,11 @@
#pragma once
-#include "Vision/OnnxRuntimeImageAnalyzer.h"
+#include "Vision/OnnxHelper.h"
namespace asst
{
// 战斗中干员(血条)检测,yolov8 模型
- class BattleOperatorsImageAnalyzer final : public OnnxRuntimeImageAnalyzer
+ class BattleOperatorsImageAnalyzer final : public OnnxHelper
{
public:
enum class Cls
@@ -20,7 +20,7 @@ namespace asst
};
public:
- using OnnxRuntimeImageAnalyzer::OnnxRuntimeImageAnalyzer;
+ using OnnxHelper::OnnxHelper;
virtual ~BattleOperatorsImageAnalyzer() override = default;
bool analyze();
diff --git a/src/MaaCore/Vision/Battle/BattleSkillReadyImageAnalyzer.h b/src/MaaCore/Vision/Battle/BattleSkillReadyImageAnalyzer.h
index 5855e5ca80..5d3143fdf7 100644
--- a/src/MaaCore/Vision/Battle/BattleSkillReadyImageAnalyzer.h
+++ b/src/MaaCore/Vision/Battle/BattleSkillReadyImageAnalyzer.h
@@ -1,13 +1,13 @@
#pragma once
-#include "Vision/OnnxRuntimeImageAnalyzer.h"
+#include "Vision/OnnxHelper.h"
namespace asst
{
- class BattleSkillReadyImageAnalyzer final : public OnnxRuntimeImageAnalyzer
+ class BattleSkillReadyImageAnalyzer final : public OnnxHelper
{
public:
- using OnnxRuntimeImageAnalyzer::OnnxRuntimeImageAnalyzer;
+ using OnnxHelper::OnnxHelper;
virtual ~BattleSkillReadyImageAnalyzer() override = default;
bool analyze();
diff --git a/src/MaaCore/Vision/BestMatchImageAnalyzer.cpp b/src/MaaCore/Vision/BestMatcher.cpp
similarity index 81%
rename from src/MaaCore/Vision/BestMatchImageAnalyzer.cpp
rename to src/MaaCore/Vision/BestMatcher.cpp
index 03f6df9e83..e93bc7f18d 100644
--- a/src/MaaCore/Vision/BestMatchImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/BestMatcher.cpp
@@ -1,23 +1,23 @@
-#include "BestMatchImageAnalyzer.h"
+#include "BestMatcher.h"
#include "Utils/NoWarningCV.h"
#include "Config/TaskData.h"
#include "Config/TemplResource.h"
-#include "MatchImageAnalyzer.h"
+#include "Matcher.h"
#include "Utils/Logger.hpp"
#include "Utils/StringMisc.hpp"
using namespace asst;
-void BestMatchImageAnalyzer::append_templ(std::string name, const cv::Mat& templ)
+void BestMatcher::append_templ(std::string name, const cv::Mat& templ)
{
m_templs.emplace_back(TemplInfo { std::move(name), templ });
}
-BestMatchImageAnalyzer::ResultOpt BestMatchImageAnalyzer::analyze() const
+BestMatcher::ResultOpt BestMatcher::analyze() const
{
- MatchImageAnalyzer match_analyzer(m_image, m_roi);
+ Matcher match_analyzer(m_image, m_roi);
match_analyzer.set_params(m_params);
#ifdef ASST_DEBUG
match_analyzer.set_log_tracing(m_log_tracing);
diff --git a/src/MaaCore/Vision/BestMatchImageAnalyzer.h b/src/MaaCore/Vision/BestMatcher.h
similarity index 83%
rename from src/MaaCore/Vision/BestMatchImageAnalyzer.h
rename to src/MaaCore/Vision/BestMatcher.h
index 46108cf74d..9b32a43168 100644
--- a/src/MaaCore/Vision/BestMatchImageAnalyzer.h
+++ b/src/MaaCore/Vision/BestMatcher.h
@@ -1,11 +1,11 @@
#pragma once
-#include "AbstractImageAnalyzer.h"
+#include "VisionHelper.h"
#include "Vision/Config/MatcherConfig.h"
namespace asst
{
- class BestMatchImageAnalyzer : public AbstractImageAnalyzer, public MatcherConfig
+ class BestMatcher : public VisionHelper, public MatcherConfig
{
public:
struct TemplInfo
@@ -30,8 +30,8 @@ namespace asst
using ResultOpt = std::optional;
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
- virtual ~BestMatchImageAnalyzer() override = default;
+ using VisionHelper::VisionHelper;
+ virtual ~BestMatcher() override = default;
void append_templ(std::string name, const cv::Mat& templ = cv::Mat());
diff --git a/src/MaaCore/Vision/HashImageAnalyzer.cpp b/src/MaaCore/Vision/Hasher.cpp
similarity index 79%
rename from src/MaaCore/Vision/HashImageAnalyzer.cpp
rename to src/MaaCore/Vision/Hasher.cpp
index 74243f9a03..5feb00ca7f 100644
--- a/src/MaaCore/Vision/HashImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Hasher.cpp
@@ -1,10 +1,10 @@
-#include "HashImageAnalyzer.h"
+#include "Hasher.h"
#include "Utils/NoWarningCV.h"
#include "Utils/Logger.hpp"
-bool asst::HashImageAnalyzer::analyze()
+bool asst::Hasher::analyze()
{
m_hash_result.clear();
m_min_dist_name.clear();
@@ -52,42 +52,42 @@ bool asst::HashImageAnalyzer::analyze()
return true;
}
-void asst::HashImageAnalyzer::set_mask_range(int lower, int upper) noexcept
+void asst::Hasher::set_mask_range(int lower, int upper) noexcept
{
m_mask_range = std::make_pair(lower, upper);
}
-void asst::HashImageAnalyzer::set_mask_range(std::pair mask_range) noexcept
+void asst::Hasher::set_mask_range(std::pair mask_range) noexcept
{
m_mask_range = std::move(mask_range);
}
-void asst::HashImageAnalyzer::set_hash_templates(std::unordered_map hash_templates) noexcept
+void asst::Hasher::set_hash_templates(std::unordered_map hash_templates) noexcept
{
m_hash_templates = std::move(hash_templates);
}
-void asst::HashImageAnalyzer::set_need_split(bool need_split) noexcept
+void asst::Hasher::set_need_split(bool need_split) noexcept
{
m_need_split = need_split;
}
-void asst::HashImageAnalyzer::set_need_bound(bool need_bound) noexcept
+void asst::Hasher::set_need_bound(bool need_bound) noexcept
{
m_need_bound = need_bound;
}
-const std::vector& asst::HashImageAnalyzer::get_min_dist_name() const noexcept
+const std::vector& asst::Hasher::get_min_dist_name() const noexcept
{
return m_min_dist_name;
}
-const std::vector& asst::HashImageAnalyzer::get_hash() const noexcept
+const std::vector& asst::Hasher::get_hash() const noexcept
{
return m_hash_result;
}
-std::string asst::HashImageAnalyzer::s_hash(const cv::Mat& img)
+std::string asst::Hasher::s_hash(const cv::Mat& img)
{
static constexpr int HashKernelSize = 16;
cv::Mat resized;
@@ -112,7 +112,7 @@ std::string asst::HashImageAnalyzer::s_hash(const cv::Mat& img)
return hash_value.str();
}
-std::vector asst::HashImageAnalyzer::split_bin(const cv::Mat& bin)
+std::vector asst::Hasher::split_bin(const cv::Mat& bin)
{
std::vector result;
@@ -147,12 +147,12 @@ std::vector asst::HashImageAnalyzer::split_bin(const cv::Mat& bin)
return result;
}
-cv::Mat asst::HashImageAnalyzer::bound_bin(const cv::Mat& bin)
+cv::Mat asst::Hasher::bound_bin(const cv::Mat& bin)
{
return bin(cv::boundingRect(bin));
}
-int asst::HashImageAnalyzer::hamming(std::string hash1, std::string hash2)
+int asst::Hasher::hamming(std::string hash1, std::string hash2)
{
static constexpr int HammingFlags = 64;
diff --git a/src/MaaCore/Vision/HashImageAnalyzer.h b/src/MaaCore/Vision/Hasher.h
similarity index 85%
rename from src/MaaCore/Vision/HashImageAnalyzer.h
rename to src/MaaCore/Vision/Hasher.h
index 4a424c00f3..eb894e2d21 100644
--- a/src/MaaCore/Vision/HashImageAnalyzer.h
+++ b/src/MaaCore/Vision/Hasher.h
@@ -1,16 +1,16 @@
#pragma once
-#include "AbstractImageAnalyzer.h"
+#include "VisionHelper.h"
#include
namespace asst
{
// FIXME: 删掉这个类,以及对应的 task 类型
- class HashImageAnalyzer : public AbstractImageAnalyzer
+ class Hasher : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
- virtual ~HashImageAnalyzer() override = default;
+ using VisionHelper::VisionHelper;
+ virtual ~Hasher() override = default;
bool analyze();
diff --git a/src/MaaCore/Vision/Infrast/InfrastClueVacancyImageAnalyzer.cpp b/src/MaaCore/Vision/Infrast/InfrastClueVacancyImageAnalyzer.cpp
index 160160b3c5..ee48841ca1 100644
--- a/src/MaaCore/Vision/Infrast/InfrastClueVacancyImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Infrast/InfrastClueVacancyImageAnalyzer.cpp
@@ -2,13 +2,13 @@
#include "Utils/Logger.hpp"
#include "Utils/NoWarningCV.h"
-#include "Vision/MatchImageAnalyzer.h"
+#include "Vision/Matcher.h"
bool asst::InfrastClueVacancyImageAnalyzer::analyze()
{
const static std::string clue_vacancy = "InfrastClueVacancy";
- MatchImageAnalyzer analyzer(m_image);
+ Matcher analyzer(m_image);
for (const std::string& suffix : m_to_be_analyzed) {
analyzer.set_task_info(clue_vacancy + suffix);
diff --git a/src/MaaCore/Vision/Infrast/InfrastClueVacancyImageAnalyzer.h b/src/MaaCore/Vision/Infrast/InfrastClueVacancyImageAnalyzer.h
index 7024447ed7..bc4c83098b 100644
--- a/src/MaaCore/Vision/Infrast/InfrastClueVacancyImageAnalyzer.h
+++ b/src/MaaCore/Vision/Infrast/InfrastClueVacancyImageAnalyzer.h
@@ -1,12 +1,12 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
namespace asst
{
- class InfrastClueVacancyImageAnalyzer final : public AbstractImageAnalyzer
+ class InfrastClueVacancyImageAnalyzer final : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~InfrastClueVacancyImageAnalyzer() override = default;
InfrastClueVacancyImageAnalyzer(const cv::Mat& image, const Rect& roi) = delete;
@@ -22,7 +22,7 @@ namespace asst
private:
// 该分析器不支持外部设置ROI
- using AbstractImageAnalyzer::set_roi;
+ using VisionHelper::set_roi;
std::vector m_to_be_analyzed;
std::unordered_map m_clue_vacancy;
diff --git a/src/MaaCore/Vision/Infrast/InfrastFacilityImageAnalyzer.cpp b/src/MaaCore/Vision/Infrast/InfrastFacilityImageAnalyzer.cpp
index a16d58a37b..85b965e485 100644
--- a/src/MaaCore/Vision/Infrast/InfrastFacilityImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Infrast/InfrastFacilityImageAnalyzer.cpp
@@ -4,7 +4,7 @@
#include "Config/TaskData.h"
#include "Utils/Logger.hpp"
-#include "Vision/MultiMatchImageAnalyzer.h"
+#include "Vision/MultiMatcher.h"
bool asst::InfrastFacilityImageAnalyzer::analyze()
{
@@ -17,7 +17,7 @@ bool asst::InfrastFacilityImageAnalyzer::analyze()
// 所以对每种情况都进行一下识别,取其中得分最高的
const static std::vector task_name_suffix = { "", "Mini" };
- MultiMatchImageAnalyzer mm_analyzer(m_image);
+ MultiMatcher mm_analyzer(m_image);
auto task_analyze = [&](const std::string& task_name) -> bool {
mm_analyzer.set_task_info(task_name);
diff --git a/src/MaaCore/Vision/Infrast/InfrastFacilityImageAnalyzer.h b/src/MaaCore/Vision/Infrast/InfrastFacilityImageAnalyzer.h
index 64077e0bc9..8412038960 100644
--- a/src/MaaCore/Vision/Infrast/InfrastFacilityImageAnalyzer.h
+++ b/src/MaaCore/Vision/Infrast/InfrastFacilityImageAnalyzer.h
@@ -1,12 +1,12 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
namespace asst
{
- class InfrastFacilityImageAnalyzer final : public AbstractImageAnalyzer
+ class InfrastFacilityImageAnalyzer final : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~InfrastFacilityImageAnalyzer() override = default;
InfrastFacilityImageAnalyzer(const cv::Mat& image, const Rect& roi) = delete;
@@ -44,7 +44,7 @@ namespace asst
private:
// 该分析器不支持外部设置ROI
- using AbstractImageAnalyzer::set_roi;
+ using VisionHelper::set_roi;
// key:设施名,value:所有这种设施的当前Rect(例如所有制造站的位置)
std::unordered_map> m_result;
diff --git a/src/MaaCore/Vision/Infrast/InfrastOperImageAnalyzer.cpp b/src/MaaCore/Vision/Infrast/InfrastOperImageAnalyzer.cpp
index 1ff2e45c08..7192927015 100644
--- a/src/MaaCore/Vision/Infrast/InfrastOperImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Infrast/InfrastOperImageAnalyzer.cpp
@@ -7,8 +7,8 @@
#include "Config/TaskData.h"
#include "InfrastSmileyImageAnalyzer.h"
#include "Utils/Logger.hpp"
-#include "Vision/HashImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
+#include "Vision/Hasher.h"
+#include "Vision/Matcher.h"
bool asst::InfrastOperImageAnalyzer::analyze()
{
@@ -209,7 +209,7 @@ void asst::InfrastOperImageAnalyzer::face_hash_analyze()
const Rect hash_rect_move = Task.get("InfrastOperFaceHash")->rect_move;
- HashImageAnalyzer hash_analyzer(m_image);
+ Hasher hash_analyzer(m_image);
for (auto&& oper : m_result) {
Rect roi = oper.smiley.rect.move(hash_rect_move);
@@ -226,7 +226,7 @@ void asst::InfrastOperImageAnalyzer::skill_analyze()
const auto task_ptr = Task.get("InfrastSkills");
const int bright_thres = task_ptr->special_params.front();
- MatchImageAnalyzer skill_analyzer(m_image);
+ Matcher skill_analyzer(m_image);
skill_analyzer.set_mask_range(task_ptr->mask_range.first, task_ptr->mask_range.second);
skill_analyzer.set_threshold(task_ptr->templ_threshold);
@@ -383,7 +383,7 @@ void asst::InfrastOperImageAnalyzer::doing_analyze()
const auto working_task_ptr = Task.get("InfrastOperOnShift");
Rect rect_move = working_task_ptr->rect_move;
- MatchImageAnalyzer working_analyzer(m_image);
+ Matcher working_analyzer(m_image);
working_analyzer.set_task_info(working_task_ptr);
diff --git a/src/MaaCore/Vision/Infrast/InfrastOperImageAnalyzer.h b/src/MaaCore/Vision/Infrast/InfrastOperImageAnalyzer.h
index a2da96bfac..4ebd8ef07b 100644
--- a/src/MaaCore/Vision/Infrast/InfrastOperImageAnalyzer.h
+++ b/src/MaaCore/Vision/Infrast/InfrastOperImageAnalyzer.h
@@ -1,11 +1,11 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
#include "Common/AsstInfrastDef.h"
namespace asst
{
- class InfrastOperImageAnalyzer : public AbstractImageAnalyzer
+ class InfrastOperImageAnalyzer : public VisionHelper
{
public:
enum ToBeCalced
@@ -21,7 +21,7 @@ namespace asst
All = 127
};
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~InfrastOperImageAnalyzer() override = default;
InfrastOperImageAnalyzer(const cv::Mat& image, const Rect& roi) = delete;
@@ -39,7 +39,7 @@ namespace asst
private:
// 该分析器不支持外部设置ROI
- using AbstractImageAnalyzer::set_roi;
+ using VisionHelper::set_roi;
void oper_detect();
void mood_analyze();
diff --git a/src/MaaCore/Vision/Infrast/InfrastSmileyImageAnalyzer.cpp b/src/MaaCore/Vision/Infrast/InfrastSmileyImageAnalyzer.cpp
index 75f8acf0b2..569573cbb9 100644
--- a/src/MaaCore/Vision/Infrast/InfrastSmileyImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Infrast/InfrastSmileyImageAnalyzer.cpp
@@ -3,7 +3,7 @@
#include "Utils/NoWarningCV.h"
#include "Utils/StringMisc.hpp"
-#include "Vision/MultiMatchImageAnalyzer.h"
+#include "Vision/MultiMatcher.h"
bool asst::InfrastSmileyImageAnalyzer::analyze()
{
@@ -15,7 +15,7 @@ bool asst::InfrastSmileyImageAnalyzer::analyze()
m_result.clear();
- MultiMatchImageAnalyzer mm_analyzer(m_image);
+ MultiMatcher mm_analyzer(m_image);
decltype(m_result) temp_result;
for (const auto& [type, task_name] : smiley_map) {
diff --git a/src/MaaCore/Vision/Infrast/InfrastSmileyImageAnalyzer.h b/src/MaaCore/Vision/Infrast/InfrastSmileyImageAnalyzer.h
index c40fef4dd8..ac1f9776f8 100644
--- a/src/MaaCore/Vision/Infrast/InfrastSmileyImageAnalyzer.h
+++ b/src/MaaCore/Vision/Infrast/InfrastSmileyImageAnalyzer.h
@@ -1,14 +1,14 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
#include "Common/AsstInfrastDef.h"
namespace asst
{
- class InfrastSmileyImageAnalyzer : public AbstractImageAnalyzer
+ class InfrastSmileyImageAnalyzer : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~InfrastSmileyImageAnalyzer() override = default;
bool analyze();
diff --git a/src/MaaCore/Vision/MatchImageAnalyzer.cpp b/src/MaaCore/Vision/Matcher.cpp
similarity index 93%
rename from src/MaaCore/Vision/MatchImageAnalyzer.cpp
rename to src/MaaCore/Vision/Matcher.cpp
index 6ed79f8647..802cf2c970 100644
--- a/src/MaaCore/Vision/MatchImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Matcher.cpp
@@ -1,4 +1,4 @@
-#include "MatchImageAnalyzer.h"
+#include "Matcher.h"
#include "Utils/NoWarningCV.h"
@@ -9,7 +9,7 @@
using namespace asst;
-MatchImageAnalyzer::ResultOpt MatchImageAnalyzer::analyze() const
+Matcher::ResultOpt Matcher::analyze() const
{
const auto& [matched, templ, templ_name] = preproc_and_match(make_roi(m_image, m_roi), m_params);
@@ -39,7 +39,7 @@ MatchImageAnalyzer::ResultOpt MatchImageAnalyzer::analyze() const
return m_result;
}
-MatchImageAnalyzer::RawResult MatchImageAnalyzer::preproc_and_match(const cv::Mat& image,
+Matcher::RawResult Matcher::preproc_and_match(const cv::Mat& image,
const MatcherConfig::Params& params)
{
cv::Mat templ;
diff --git a/src/MaaCore/Vision/MatchImageAnalyzer.h b/src/MaaCore/Vision/Matcher.h
similarity index 79%
rename from src/MaaCore/Vision/MatchImageAnalyzer.h
rename to src/MaaCore/Vision/Matcher.h
index 6cd5162973..bd7ed182c1 100644
--- a/src/MaaCore/Vision/MatchImageAnalyzer.h
+++ b/src/MaaCore/Vision/Matcher.h
@@ -1,19 +1,19 @@
#pragma once
-#include "AbstractImageAnalyzer.h"
+#include "VisionHelper.h"
#include "Vision/Config/MatcherConfig.h"
namespace asst
{
- class MatchImageAnalyzer : public AbstractImageAnalyzer, public MatcherConfig
+ class Matcher : public VisionHelper, public MatcherConfig
{
public:
using Result = MatchRect;
using ResultOpt = std::optional;
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
- virtual ~MatchImageAnalyzer() override = default;
+ using VisionHelper::VisionHelper;
+ virtual ~Matcher() override = default;
ResultOpt analyze() const;
// FIXME: 老接口太难重构了,先弄个这玩意兼容下,后续慢慢全删掉
diff --git a/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.cpp
index ee2445a7a1..073db5a25d 100644
--- a/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.cpp
@@ -6,9 +6,9 @@
#include "Config/TaskData.h"
#include "Utils/Logger.hpp"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/MultiMatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/MultiMatcher.h"
+#include "Vision/OCRer.h"
void asst::CreditShopImageAnalyzer::set_black_list(std::vector black_list)
{
@@ -39,7 +39,7 @@ bool asst::CreditShopImageAnalyzer::commodities_analyze()
{
// 识别信用点的图标
const auto commodity_task_ptr = Task.get("CreditShop-Commodities");
- MultiMatchImageAnalyzer mm_analyzer(m_image);
+ MultiMatcher mm_analyzer(m_image);
mm_analyzer.set_task_info(commodity_task_ptr);
if (!mm_analyzer.analyze()) {
@@ -77,7 +77,7 @@ bool asst::CreditShopImageAnalyzer::whether_to_buy_analyze()
name_roi.x += commodity.x;
name_roi.y += commodity.y;
- OcrImageAnalyzer ocr_analyzer(m_image);
+ OCRer ocr_analyzer(m_image);
ocr_analyzer.set_roi(name_roi);
ocr_analyzer.set_replace(product_name_task_ptr->replace_map);
ocr_analyzer.set_required(m_shopping_list);
@@ -112,7 +112,7 @@ bool asst::CreditShopImageAnalyzer::whether_to_buy_analyze()
bool asst::CreditShopImageAnalyzer::sold_out_analyze()
{
// 识别是否售罄
- MatchImageAnalyzer sold_out_analyzer(m_image);
+ Matcher sold_out_analyzer(m_image);
sold_out_analyzer.set_task_info("CreditShop-SoldOut");
for (const auto& commodity : m_need_to_buy | views::keys) {
diff --git a/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.h b/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.h
index cd622345a6..67dcf4a6db 100644
--- a/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.h
+++ b/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.h
@@ -1,12 +1,12 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
namespace asst
{
- class CreditShopImageAnalyzer final : public AbstractImageAnalyzer
+ class CreditShopImageAnalyzer final : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~CreditShopImageAnalyzer() override = default;
bool analyze();
@@ -18,7 +18,7 @@ namespace asst
private:
// 该分析器不支持外部设置ROI
- using AbstractImageAnalyzer::set_roi;
+ using VisionHelper::set_roi;
bool commodities_analyze();
bool whether_to_buy_analyze();
bool sold_out_analyze();
diff --git a/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.cpp
index 7f5bf235bc..208d98388e 100644
--- a/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.cpp
@@ -6,8 +6,8 @@
#include "Config/TaskData.h"
#include "Config/TemplResource.h"
#include "Utils/Logger.hpp"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/RegionOCRer.h"
#include
@@ -172,7 +172,7 @@ size_t asst::DepotImageAnalyzer::match_item(const Rect& roi, /* out */ ItemInfo&
const auto& all_items = ItemData.get_ordered_material_item_id();
- MatchImageAnalyzer analyzer(m_image_resized);
+ Matcher analyzer(m_image_resized);
analyzer.set_task_info("DepotMatchData");
// spacing 有时候算的差一个像素,干脆把 roi 扩大一点好了
Rect enlarged_roi = roi;
@@ -253,7 +253,7 @@ int asst::DepotImageAnalyzer::match_quantity(const ItemInfo& item)
cv::subtract(m_image_resized(make_rect(item.rect)), item_templ * 0.41,
ocr_img(make_rect(item.rect)));
- OcrWithPreprocessImageAnalyzer analyzer(m_image_resized);
+ RegionOCRer analyzer(m_image_resized);
analyzer.set_task_info("NumberOcrReplace");
analyzer.set_roi(ocr_roi);
analyzer.set_bin_threshold(task_ptr->mask_range.first, task_ptr->mask_range.second);
diff --git a/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.h b/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.h
index 4b72b547cb..d1ebbe2ec7 100644
--- a/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.h
+++ b/src/MaaCore/Vision/Miscellaneous/DepotImageAnalyzer.h
@@ -1,5 +1,5 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
namespace asst
{
@@ -10,13 +10,13 @@ namespace asst
int quantity = 0;
Rect rect;
};
- class DepotImageAnalyzer final : public AbstractImageAnalyzer
+ class DepotImageAnalyzer final : public VisionHelper
{
public:
static constexpr size_t NPos = ~0ULL;
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~DepotImageAnalyzer() override = default;
bool analyze();
diff --git a/src/MaaCore/Vision/Miscellaneous/OperBoxImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/OperBoxImageAnalyzer.cpp
index 0bccad58a5..cc642746f3 100644
--- a/src/MaaCore/Vision/Miscellaneous/OperBoxImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Miscellaneous/OperBoxImageAnalyzer.cpp
@@ -5,11 +5,11 @@
#include "Config/Miscellaneous/BattleDataConfig.h"
#include "Config/TaskData.h"
#include "Utils/Logger.hpp"
-#include "Vision/BestMatchImageAnalyzer.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/MultiMatchImageAnalyzer.h"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/BestMatcher.h"
+#include "Vision/Matcher.h"
+#include "Vision/MultiMatcher.h"
+#include "Vision/TemplDetOCRer.h"
+#include "Vision/RegionOCRer.h"
bool asst::OperBoxImageAnalyzer::analyze()
{
@@ -59,7 +59,7 @@ bool asst::OperBoxImageAnalyzer::opers_analyze()
{
const auto& ocr_replace = Task.get("CharsNameOcrReplace");
- OcrWithFlagTemplImageAnalyzer oper_name_analyzer(m_image);
+ TemplDetOCRer oper_name_analyzer(m_image);
oper_name_analyzer.set_task_info("OperBoxFlagLV", "OperBoxNameOCR");
oper_name_analyzer.set_replace(ocr_replace->replace_map, ocr_replace->replace_full);
@@ -95,7 +95,7 @@ bool asst::OperBoxImageAnalyzer::opers_analyze()
// 识别等级
bool asst::OperBoxImageAnalyzer::level_analyze()
{
- OcrWithPreprocessImageAnalyzer level_analyzer(m_image);
+ RegionOCRer level_analyzer(m_image);
level_analyzer.set_task_info("OperBoxLevelOCR");
const Rect level_roi = Task.get("OperBoxLevelOCR")->roi;
@@ -131,7 +131,7 @@ bool asst::OperBoxImageAnalyzer::elite_analyze()
{
const std::string task_name = "OperBoxFlagElite";
const Rect elite_roi = Task.get(task_name)->roi;
- BestMatchImageAnalyzer elite_analyzer(m_image);
+ BestMatcher elite_analyzer(m_image);
elite_analyzer.set_task_info(task_name);
elite_analyzer.append_templ("OperBoxFlagElite1.png");
elite_analyzer.append_templ("OperBoxFlagElite2.png");
@@ -162,7 +162,7 @@ bool asst::OperBoxImageAnalyzer::potential_analyze()
{
const std::string task_name_p = "OperBoxPotential";
const Rect potential_roi = Task.get(task_name_p)->roi;
- BestMatchImageAnalyzer potential_analyzer(m_image);
+ BestMatcher potential_analyzer(m_image);
potential_analyzer.set_task_info(task_name_p);
for (int i = 1; i < 6; i++) {
std::string potential_temp_name = task_name_p + std::to_string(i) + ".png";
diff --git a/src/MaaCore/Vision/Miscellaneous/OperBoxImageAnalyzer.h b/src/MaaCore/Vision/Miscellaneous/OperBoxImageAnalyzer.h
index ee2ff8972c..6dbf778b99 100644
--- a/src/MaaCore/Vision/Miscellaneous/OperBoxImageAnalyzer.h
+++ b/src/MaaCore/Vision/Miscellaneous/OperBoxImageAnalyzer.h
@@ -1,6 +1,6 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
namespace asst
{
@@ -16,10 +16,10 @@ namespace asst
Rect rect;
bool own = false;
};
- class OperBoxImageAnalyzer final : public AbstractImageAnalyzer
+ class OperBoxImageAnalyzer final : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~OperBoxImageAnalyzer() override = default;
bool analyze();
const auto& get_result() const noexcept { return m_result; }
diff --git a/src/MaaCore/Vision/Miscellaneous/ProcessTaskImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/PipelineAnalyzer.cpp
similarity index 82%
rename from src/MaaCore/Vision/Miscellaneous/ProcessTaskImageAnalyzer.cpp
rename to src/MaaCore/Vision/Miscellaneous/PipelineAnalyzer.cpp
index 5d1f606802..7ef9412353 100644
--- a/src/MaaCore/Vision/Miscellaneous/ProcessTaskImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Miscellaneous/PipelineAnalyzer.cpp
@@ -1,4 +1,4 @@
-#include "ProcessTaskImageAnalyzer.h"
+#include "PipelineAnalyzer.h"
#include
#include
@@ -6,13 +6,13 @@
#include "Config/TaskData.h"
#include "Status.h"
#include "Utils/Logger.hpp"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/OCRer.h"
+#include "Vision/RegionOCRer.h"
using namespace asst;
-ProcessTaskImageAnalyzer::ResultOpt ProcessTaskImageAnalyzer::analyze() const
+PipelineAnalyzer::ResultOpt PipelineAnalyzer::analyze() const
{
for (const std::string& task_name : m_tasks_name) {
const auto& task_ptr = Task.get(task_name);
@@ -48,9 +48,9 @@ ProcessTaskImageAnalyzer::ResultOpt ProcessTaskImageAnalyzer::analyze() const
return std::nullopt;
}
-MatchImageAnalyzer::ResultOpt ProcessTaskImageAnalyzer::match(const std::shared_ptr& task_ptr) const
+Matcher::ResultOpt PipelineAnalyzer::match(const std::shared_ptr& task_ptr) const
{
- MatchImageAnalyzer match_analyzer(m_image, m_roi);
+ Matcher match_analyzer(m_image, m_roi);
const auto match_task_ptr = std::dynamic_pointer_cast(task_ptr);
if (match_task_ptr->templ_threshold > 1.0) {
@@ -79,7 +79,7 @@ MatchImageAnalyzer::ResultOpt ProcessTaskImageAnalyzer::match(const std::shared_
return result_opt;
}
-OcrImageAnalyzer::ResultsVecOpt ProcessTaskImageAnalyzer::ocr(const std::shared_ptr& task_ptr) const
+OCRer::ResultsVecOpt PipelineAnalyzer::ocr(const std::shared_ptr& task_ptr) const
{
const auto ocr_task_ptr = std::dynamic_pointer_cast(task_ptr);
@@ -91,10 +91,10 @@ OcrImageAnalyzer::ResultsVecOpt ProcessTaskImageAnalyzer::ocr(const std::shared_
cache_opt = status()->get_rect(ocr_task_ptr->name);
}
- OcrImageAnalyzer::ResultsVec result_vec;
+ OCRer::ResultsVec result_vec;
if (det) {
- OcrImageAnalyzer analyzer(m_image, m_roi);
+ OCRer analyzer(m_image, m_roi);
analyzer.set_task_info(ocr_task_ptr);
if (use_cache && cache_opt) {
analyzer.set_roi(*cache_opt);
@@ -107,7 +107,7 @@ OcrImageAnalyzer::ResultsVecOpt ProcessTaskImageAnalyzer::ocr(const std::shared_
result_vec = std::move(*result_opt);
}
else {
- OcrWithPreprocessImageAnalyzer analyzer(m_image, m_roi);
+ RegionOCRer analyzer(m_image, m_roi);
analyzer.set_task_info(ocr_task_ptr);
if (use_cache && cache_opt) {
analyzer.set_roi(*cache_opt);
diff --git a/src/MaaCore/Vision/Miscellaneous/PipelineAnalyzer.h b/src/MaaCore/Vision/Miscellaneous/PipelineAnalyzer.h
new file mode 100644
index 0000000000..ee0069d105
--- /dev/null
+++ b/src/MaaCore/Vision/Miscellaneous/PipelineAnalyzer.h
@@ -0,0 +1,40 @@
+#pragma once
+#include "Vision/VisionHelper.h"
+
+#include
+#include
+#include
+
+#include "Common/AsstTypes.h"
+
+#include "Vision/Matcher.h"
+#include "Vision/OCRer.h"
+
+namespace asst
+{
+ class PipelineAnalyzer : public VisionHelper
+ {
+ public:
+ struct Result
+ {
+ std::shared_ptr task_ptr;
+ std::variant result;
+ Rect rect;
+ };
+ using ResultOpt = std::optional;
+
+ public:
+ using VisionHelper::VisionHelper;
+ virtual ~PipelineAnalyzer() override = default;
+
+ void set_tasks(std::vector tasks_name) { m_tasks_name = std::move(tasks_name); }
+
+ ResultOpt analyze() const;
+
+ private:
+ Matcher::ResultOpt match(const std::shared_ptr& task_ptr) const;
+ OCRer::ResultsVecOpt ocr(const std::shared_ptr& task_ptr) const;
+
+ std::vector m_tasks_name;
+ };
+}
diff --git a/src/MaaCore/Vision/Miscellaneous/ProcessTaskImageAnalyzer.h b/src/MaaCore/Vision/Miscellaneous/ProcessTaskImageAnalyzer.h
deleted file mode 100644
index bf969c9a4d..0000000000
--- a/src/MaaCore/Vision/Miscellaneous/ProcessTaskImageAnalyzer.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
-
-#include
-#include
-#include
-
-#include "Common/AsstTypes.h"
-
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
-
-namespace asst
-{
- class ProcessTaskImageAnalyzer : public AbstractImageAnalyzer
- {
- public:
- struct Result
- {
- std::shared_ptr task_ptr;
- std::variant result;
- Rect rect;
- };
- using ResultOpt = std::optional;
-
- public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
- virtual ~ProcessTaskImageAnalyzer() override = default;
-
- void set_tasks(std::vector tasks_name) { m_tasks_name = std::move(tasks_name); }
-
- ResultOpt analyze() const;
-
- private:
- MatchImageAnalyzer::ResultOpt match(const std::shared_ptr& task_ptr) const;
- OcrImageAnalyzer::ResultsVecOpt ocr(const std::shared_ptr& task_ptr) const;
-
- std::vector m_tasks_name;
- };
-}
diff --git a/src/MaaCore/Vision/Miscellaneous/RecruitImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/RecruitImageAnalyzer.cpp
index 66c329500a..4f570770bc 100644
--- a/src/MaaCore/Vision/Miscellaneous/RecruitImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Miscellaneous/RecruitImageAnalyzer.cpp
@@ -2,9 +2,9 @@
#include "Config/Miscellaneous/RecruitConfig.h"
#include "Config/TaskData.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/MultiMatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/MultiMatcher.h"
+#include "Vision/OCRer.h"
bool asst::RecruitImageAnalyzer::analyze()
{
@@ -20,7 +20,7 @@ bool asst::RecruitImageAnalyzer::analyze()
bool asst::RecruitImageAnalyzer::tags_analyze()
{
static bool analyzer_inited = false;
- static OcrImageAnalyzer tags_analyzer;
+ static OCRer tags_analyzer;
if (!analyzer_inited) {
tags_analyzer.set_task_info("RecruitTags");
auto& all_tags_set = RecruitData.get_all_tags();
@@ -44,7 +44,7 @@ bool asst::RecruitImageAnalyzer::tags_analyze()
bool asst::RecruitImageAnalyzer::time_analyze()
{
- MultiMatchImageAnalyzer decrement_a(m_image);
+ MultiMatcher decrement_a(m_image);
decrement_a.set_task_info("RecruitTimerDecrement");
auto result_opt = decrement_a.analyze();
if (!result_opt) return false;
@@ -57,7 +57,7 @@ bool asst::RecruitImageAnalyzer::time_analyze()
bool asst::RecruitImageAnalyzer::refresh_analyze()
{
- MatchImageAnalyzer refresh_analyzer(m_image);
+ Matcher refresh_analyzer(m_image);
refresh_analyzer.set_task_info("RecruitRefresh");
diff --git a/src/MaaCore/Vision/Miscellaneous/RecruitImageAnalyzer.h b/src/MaaCore/Vision/Miscellaneous/RecruitImageAnalyzer.h
index 09b2e47771..2369893709 100644
--- a/src/MaaCore/Vision/Miscellaneous/RecruitImageAnalyzer.h
+++ b/src/MaaCore/Vision/Miscellaneous/RecruitImageAnalyzer.h
@@ -1,14 +1,14 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
#include "Common/AsstTypes.h"
namespace asst
{
- class RecruitImageAnalyzer final : public AbstractImageAnalyzer
+ class RecruitImageAnalyzer final : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
RecruitImageAnalyzer(const cv::Mat& image, const Rect& roi) = delete;
virtual ~RecruitImageAnalyzer() override = default;
@@ -21,7 +21,7 @@ namespace asst
private:
// 该分析器不支持外部设置ROI
- using AbstractImageAnalyzer::set_roi;
+ using VisionHelper::set_roi;
bool tags_analyze();
bool time_analyze();
bool refresh_analyze();
diff --git a/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp
index 20174064fe..212def6002 100644
--- a/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp
@@ -10,9 +10,9 @@
#include "Config/TemplResource.h"
#include "Utils/ImageIo.hpp"
#include "Utils/Logger.hpp"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/TemplDetOCRer.h"
+#include "Vision/RegionOCRer.h"
#include
@@ -47,7 +47,7 @@ bool asst::StageDropsImageAnalyzer::analyze_stage_code()
{
LogTraceFunction;
- OcrImageAnalyzer analyzer(m_image);
+ OCRer analyzer(m_image);
analyzer.set_task_info("StageDrops-StageName");
if (!analyzer.analyze()) {
return false;
@@ -74,7 +74,7 @@ bool asst::StageDropsImageAnalyzer::analyze_stars()
{ 3, "StageDrops-Stars-3" },
};
- MatchImageAnalyzer analyzer(m_image);
+ Matcher analyzer(m_image);
int matched_stars = 0;
double max_score = 0.0;
@@ -117,7 +117,7 @@ bool asst::StageDropsImageAnalyzer::analyze_difficulty()
LogTraceFunction;
auto task_ptr = Task.get("StageDrops-Difficulty-Tough");
- MatchImageAnalyzer analyzer(m_image);
+ Matcher analyzer(m_image);
analyzer.set_task_info(task_ptr);
auto log = [&]() {
@@ -245,7 +245,7 @@ bool asst::StageDropsImageAnalyzer::analyze_drops_for_CF()
bool has_error = false;
- OcrImageAnalyzer food_analyzer(m_image);
+ OCRer food_analyzer(m_image);
food_analyzer.set_task_info("StageDrops-StageCF-FoodBonusFlag");
if (food_analyzer.analyze()) {
// 这个企鹅物流不收,而且也不好识别,直接报错拉倒
@@ -253,7 +253,7 @@ bool asst::StageDropsImageAnalyzer::analyze_drops_for_CF()
has_error = true;
}
- OcrWithFlagTemplImageAnalyzer analyzer(m_image);
+ TemplDetOCRer analyzer(m_image);
for (const auto& item_name : CFDrops) {
analyzer.set_task_info(item_name, "StageDrops-StageCF-ItemQuantity");
if (!analyzer.analyze()) {
@@ -294,7 +294,7 @@ bool asst::StageDropsImageAnalyzer::analyze_drops_for_12()
}
LogTraceFunction;
- OcrImageAnalyzer flag_analyzer(m_image);
+ OCRer flag_analyzer(m_image);
flag_analyzer.set_task_info("StageDrops-Stage12-TripleFlag");
return !flag_analyzer.analyze();
}
@@ -414,7 +414,7 @@ asst::StageDropType asst::StageDropsImageAnalyzer::match_droptype(const Rect& ro
{ StageDropType::Reward, "StageDrops-DropType-Reward" },
};
- MatchImageAnalyzer analyzer(m_image);
+ Matcher analyzer(m_image);
auto matched = StageDropType::Unknown;
double max_score = 0.0;
@@ -487,7 +487,7 @@ std::string asst::StageDropsImageAnalyzer::match_item(const Rect& roi, StageDrop
}
auto match_item_with_templs = [&](const std::vector& templs_list) -> std::string {
- MatchImageAnalyzer analyzer(m_image);
+ Matcher analyzer(m_image);
analyzer.set_mask_range(0, 0, false, true);
analyzer.set_task_info("StageDrops-Item");
analyzer.set_roi(roi);
@@ -584,7 +584,7 @@ std::optional asst::StageDropsImageAnalyzer::match_quantity_stri
int far_left = contours.back().start;
int far_right = contours.front().end;
- OcrWithPreprocessImageAnalyzer analyzer(m_image);
+ RegionOCRer analyzer(m_image);
analyzer.set_task_info("NumberOcrReplace");
analyzer.set_roi(Rect(quantity_roi.x + far_left, quantity_roi.y, far_right - far_left, quantity_roi.height));
analyzer.set_bin_threshold(task_ptr->mask_range.first, task_ptr->mask_range.second);
@@ -608,7 +608,7 @@ std::optional asst::StageDropsImageAnalyzer::match_quantity_stri
return std::nullopt;
}
- MatchImageAnalyzer analyzer(m_image);
+ Matcher analyzer(m_image);
analyzer.set_templ(templ);
analyzer.set_mask_range(1, 255, false, true);
analyzer.set_roi(roi);
@@ -650,7 +650,7 @@ std::optional asst::StageDropsImageAnalyzer::match_quantity_stri
cv::Mat ocr_img = m_image.clone();
cv::subtract(ocr_img(make_rect(new_roi)), templ * 0.41, ocr_img(make_rect(new_roi)));
- OcrWithPreprocessImageAnalyzer ocr(ocr_img);
+ RegionOCRer ocr(ocr_img);
ocr.set_task_info("NumberOcrReplace");
Rect ocr_roi { new_roi.x + mask_rect.x, new_roi.y + mask_rect.y, mask_rect.width, mask_rect.height };
ocr.set_roi(ocr_roi);
diff --git a/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.h b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.h
index a21572ef40..949eac8a9f 100644
--- a/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.h
+++ b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.h
@@ -1,17 +1,17 @@
#pragma once
#include "Config/Miscellaneous/StageDropsConfig.h"
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
#include
namespace asst
{
- class StageDropsImageAnalyzer final : public AbstractImageAnalyzer
+ class StageDropsImageAnalyzer final : public VisionHelper
{
static constexpr const char* LMD_ID = "4001";
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~StageDropsImageAnalyzer() override = default;
bool analyze();
diff --git a/src/MaaCore/Vision/MultiMatchImageAnalyzer.cpp b/src/MaaCore/Vision/MultiMatcher.cpp
similarity index 90%
rename from src/MaaCore/Vision/MultiMatchImageAnalyzer.cpp
rename to src/MaaCore/Vision/MultiMatcher.cpp
index de94fb0d07..7f15c29837 100644
--- a/src/MaaCore/Vision/MultiMatchImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/MultiMatcher.cpp
@@ -1,4 +1,4 @@
-#include "MultiMatchImageAnalyzer.h"
+#include "MultiMatcher.h"
#include "Utils/Ranges.hpp"
#include
@@ -8,14 +8,14 @@
#include "Config/TaskData.h"
#include "Config/TemplResource.h"
#include "Utils/Logger.hpp"
-#include "Vision/MatchImageAnalyzer.h"
+#include "Vision/Matcher.h"
using namespace asst;
-MultiMatchImageAnalyzer::ResultsVecOpt MultiMatchImageAnalyzer::analyze() const
+MultiMatcher::ResultsVecOpt MultiMatcher::analyze() const
{
const auto& [matched, templ, templ_name] =
- MatchImageAnalyzer::preproc_and_match(make_roi(m_image, m_roi), m_params);
+ Matcher::preproc_and_match(make_roi(m_image, m_roi), m_params);
if (matched.empty()) {
return std::nullopt;
diff --git a/src/MaaCore/Vision/MultiMatchImageAnalyzer.h b/src/MaaCore/Vision/MultiMatcher.h
similarity index 73%
rename from src/MaaCore/Vision/MultiMatchImageAnalyzer.h
rename to src/MaaCore/Vision/MultiMatcher.h
index 3a01ebd45d..2c8edc272a 100644
--- a/src/MaaCore/Vision/MultiMatchImageAnalyzer.h
+++ b/src/MaaCore/Vision/MultiMatcher.h
@@ -1,10 +1,10 @@
#pragma once
-#include "AbstractImageAnalyzer.h"
+#include "VisionHelper.h"
#include "Vision/Config/MatcherConfig.h"
namespace asst
{
- class MultiMatchImageAnalyzer : public AbstractImageAnalyzer, public MatcherConfig
+ class MultiMatcher : public VisionHelper, public MatcherConfig
{
public:
using Result = MatchRect;
@@ -12,8 +12,8 @@ namespace asst
using ResultsVecOpt = std::optional;
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
- virtual ~MultiMatchImageAnalyzer() override = default;
+ using VisionHelper::VisionHelper;
+ virtual ~MultiMatcher() override = default;
ResultsVecOpt analyze() const;
// FIXME: 老接口太难重构了,先弄个这玩意兼容下,后续慢慢全删掉
diff --git a/src/MaaCore/Vision/OcrImageAnalyzer.cpp b/src/MaaCore/Vision/OCRer.cpp
similarity index 85%
rename from src/MaaCore/Vision/OcrImageAnalyzer.cpp
rename to src/MaaCore/Vision/OCRer.cpp
index 57e8c6104f..b7bdd27e1f 100644
--- a/src/MaaCore/Vision/OcrImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/OCRer.cpp
@@ -1,4 +1,4 @@
-#include "OcrImageAnalyzer.h"
+#include "OCRer.h"
#include
#include
@@ -10,7 +10,7 @@
using namespace asst;
-OcrImageAnalyzer::ResultsVecOpt OcrImageAnalyzer::analyze() const
+OCRer::ResultsVecOpt OCRer::analyze() const
{
OcrPack* ocr_ptr = nullptr;
if (m_params.use_char_model) {
@@ -51,7 +51,7 @@ OcrImageAnalyzer::ResultsVecOpt OcrImageAnalyzer::analyze() const
return m_result;
}
-void OcrImageAnalyzer::postproc_rect_(Result& res) const
+void OCRer::postproc_rect_(Result& res) const
{
if (m_params.without_det) {
res.rect = m_roi;
@@ -62,18 +62,18 @@ void OcrImageAnalyzer::postproc_rect_(Result& res) const
}
}
-void OcrImageAnalyzer::postproc_trim_(Result& res) const
+void OCRer::postproc_trim_(Result& res) const
{
utils::string_trim(res.text);
}
-void OcrImageAnalyzer::postproc_equivalence_(Result& res) const
+void OCRer::postproc_equivalence_(Result& res) const
{
auto& ocr_config = OcrConfig::get_instance();
res.text = ocr_config.process_equivalence_class(res.text);
}
-void OcrImageAnalyzer::postproc_replace_(Result& res) const
+void OCRer::postproc_replace_(Result& res) const
{
if (m_params.replace.empty()) {
return;
@@ -91,7 +91,7 @@ void OcrImageAnalyzer::postproc_replace_(Result& res) const
}
}
-bool OcrImageAnalyzer::filter_and_replace_by_required_(Result& res) const
+bool OCRer::filter_and_replace_by_required_(Result& res) const
{
if (m_params.required.empty()) {
return true;
diff --git a/src/MaaCore/Vision/OcrImageAnalyzer.h b/src/MaaCore/Vision/OCRer.h
similarity index 83%
rename from src/MaaCore/Vision/OcrImageAnalyzer.h
rename to src/MaaCore/Vision/OCRer.h
index ad50d7efb8..73a9e39bd2 100644
--- a/src/MaaCore/Vision/OcrImageAnalyzer.h
+++ b/src/MaaCore/Vision/OCRer.h
@@ -1,5 +1,5 @@
#pragma once
-#include "AbstractImageAnalyzer.h"
+#include "VisionHelper.h"
#include "Common/AsstTypes.h"
#include "Config/Miscellaneous/OcrPack.h"
@@ -7,7 +7,7 @@
namespace asst
{
- class OcrImageAnalyzer : public AbstractImageAnalyzer, public OCRerConfig
+ class OCRer : public VisionHelper, public OCRerConfig
{
public:
using Result = OcrPack::Result;
@@ -15,8 +15,8 @@ namespace asst
using ResultsVecOpt = std::optional;
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
- virtual ~OcrImageAnalyzer() override = default;
+ using VisionHelper::VisionHelper;
+ virtual ~OCRer() override = default;
ResultsVecOpt analyze() const;
// FIXME: 老接口太难重构了,先弄个这玩意兼容下,后续慢慢全删掉
diff --git a/src/MaaCore/Vision/OnnxRuntimeImageAnalyzer.cpp b/src/MaaCore/Vision/OnnxHelper.cpp
similarity index 82%
rename from src/MaaCore/Vision/OnnxRuntimeImageAnalyzer.cpp
rename to src/MaaCore/Vision/OnnxHelper.cpp
index 042df9d387..ce67697bf2 100644
--- a/src/MaaCore/Vision/OnnxRuntimeImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/OnnxHelper.cpp
@@ -1,8 +1,8 @@
-#include "OnnxRuntimeImageAnalyzer.h"
+#include "OnnxHelper.h"
#include "Utils/NoWarningCV.h"
-std::vector asst::OnnxRuntimeImageAnalyzer::image_to_tensor(const cv::Mat& image)
+std::vector asst::OnnxHelper::image_to_tensor(const cv::Mat& image)
{
cv::Mat src = image.clone();
cv::cvtColor(src, src, cv::COLOR_BGR2RGB);
@@ -17,7 +17,7 @@ std::vector asst::OnnxRuntimeImageAnalyzer::image_to_tensor(const cv::Mat
return tensor;
}
-cv::Mat asst::OnnxRuntimeImageAnalyzer::hwc_to_chw(const cv::Mat& src)
+cv::Mat asst::OnnxHelper::hwc_to_chw(const cv::Mat& src)
{
std::vector rgb_images;
cv::split(src, rgb_images);
diff --git a/src/MaaCore/Vision/OnnxRuntimeImageAnalyzer.h b/src/MaaCore/Vision/OnnxHelper.h
similarity index 75%
rename from src/MaaCore/Vision/OnnxRuntimeImageAnalyzer.h
rename to src/MaaCore/Vision/OnnxHelper.h
index 5423b4469e..50e3829c2d 100644
--- a/src/MaaCore/Vision/OnnxRuntimeImageAnalyzer.h
+++ b/src/MaaCore/Vision/OnnxHelper.h
@@ -1,14 +1,14 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
namespace asst
{
- class OnnxRuntimeImageAnalyzer : public AbstractImageAnalyzer
+ class OnnxHelper : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
- virtual ~OnnxRuntimeImageAnalyzer() override = default;
+ using VisionHelper::VisionHelper;
+ virtual ~OnnxHelper() override = default;
protected:
template
diff --git a/src/MaaCore/Vision/OcrWithPreprocessImageAnalyzer.cpp b/src/MaaCore/Vision/RegionOCRer.cpp
similarity index 85%
rename from src/MaaCore/Vision/OcrWithPreprocessImageAnalyzer.cpp
rename to src/MaaCore/Vision/RegionOCRer.cpp
index e0eda739a2..44d31b33bc 100644
--- a/src/MaaCore/Vision/OcrWithPreprocessImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/RegionOCRer.cpp
@@ -1,10 +1,10 @@
-#include "OcrWithPreprocessImageAnalyzer.h"
+#include "RegionOCRer.h"
#include "Utils/NoWarningCV.h"
using namespace asst;
-OcrWithPreprocessImageAnalyzer::ResultOpt OcrWithPreprocessImageAnalyzer::analyze() const
+RegionOCRer::ResultOpt RegionOCRer::analyze() const
{
cv::Mat img_roi = make_roi(m_image, m_roi);
cv::Mat img_roi_gray;
@@ -33,7 +33,7 @@ OcrWithPreprocessImageAnalyzer::ResultOpt OcrWithPreprocessImageAnalyzer::analyz
cv::rectangle(m_image_draw, make_rect(new_roi), cv::Scalar(0, 0, 255), 1);
#endif // ASST_DEBUG
- OcrImageAnalyzer ocr_analyzer(m_image, new_roi);
+ OCRer ocr_analyzer(m_image, new_roi);
auto config = m_params;
config.without_det = true;
ocr_analyzer.set_params(std::move(config));
diff --git a/src/MaaCore/Vision/OcrWithPreprocessImageAnalyzer.h b/src/MaaCore/Vision/RegionOCRer.h
similarity index 66%
rename from src/MaaCore/Vision/OcrWithPreprocessImageAnalyzer.h
rename to src/MaaCore/Vision/RegionOCRer.h
index 4e8c6b3d83..48504908ad 100644
--- a/src/MaaCore/Vision/OcrWithPreprocessImageAnalyzer.h
+++ b/src/MaaCore/Vision/RegionOCRer.h
@@ -1,17 +1,17 @@
#pragma once
-#include "OcrImageAnalyzer.h"
+#include "OCRer.h"
namespace asst
{
- class OcrWithPreprocessImageAnalyzer : public AbstractImageAnalyzer, public OCRerConfig
+ class RegionOCRer : public VisionHelper, public OCRerConfig
{
public:
- using Result = OcrImageAnalyzer::Result;
+ using Result = OCRer::Result;
using ResultOpt = std::optional;
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
- virtual ~OcrWithPreprocessImageAnalyzer() override = default;
+ using VisionHelper::VisionHelper;
+ virtual ~RegionOCRer() override = default;
ResultOpt analyze() const;
// FIXME: 老接口太难重构了,先弄个这玩意兼容下,后续慢慢全删掉
diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeFormationImageAnalyzer.cpp b/src/MaaCore/Vision/Roguelike/RoguelikeFormationImageAnalyzer.cpp
index 61dbc14d2e..b513901b65 100644
--- a/src/MaaCore/Vision/Roguelike/RoguelikeFormationImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Roguelike/RoguelikeFormationImageAnalyzer.cpp
@@ -4,14 +4,14 @@
#include "Config/TaskData.h"
#include "Utils/Logger.hpp"
-#include "Vision/MultiMatchImageAnalyzer.h"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
+#include "Vision/MultiMatcher.h"
+#include "Vision/TemplDetOCRer.h"
bool asst::RoguelikeFormationImageAnalyzer::analyze()
{
m_result.clear();
- OcrWithFlagTemplImageAnalyzer analyzer(m_image);
+ TemplDetOCRer analyzer(m_image);
analyzer.set_task_info("RoguelikeFormationOper", "RoguelikeFormationOcr");
auto replace_task = Task.get("CharsNameOcrReplace");
analyzer.set_replace(replace_task->replace_map, replace_task->replace_full);
diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeFormationImageAnalyzer.h b/src/MaaCore/Vision/Roguelike/RoguelikeFormationImageAnalyzer.h
index a5e89d4b2b..1d6d6a6976 100644
--- a/src/MaaCore/Vision/Roguelike/RoguelikeFormationImageAnalyzer.h
+++ b/src/MaaCore/Vision/Roguelike/RoguelikeFormationImageAnalyzer.h
@@ -1,9 +1,9 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
namespace asst
{
- class RoguelikeFormationImageAnalyzer final : public AbstractImageAnalyzer
+ class RoguelikeFormationImageAnalyzer final : public VisionHelper
{
public:
struct FormationOper
@@ -16,7 +16,7 @@ namespace asst
};
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~RoguelikeFormationImageAnalyzer() override = default;
bool analyze();
@@ -25,7 +25,7 @@ namespace asst
protected:
// 该分析器不支持外部设置ROI
- using AbstractImageAnalyzer::set_roi;
+ using VisionHelper::set_roi;
bool selected_analyze(const Rect& roi);
diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.cpp b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.cpp
index c495771ea0..e121e7c5e4 100644
--- a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.cpp
@@ -3,15 +3,15 @@
#include "Config/TaskData.h"
#include "Utils/Logger.hpp"
#include "Utils/NoWarningCV.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/TemplDetOCRer.h"
+#include "Vision/RegionOCRer.h"
bool asst::RoguelikeRecruitImageAnalyzer::analyze()
{
LogTraceFunction;
- OcrWithFlagTemplImageAnalyzer analyzer(m_image);
+ TemplDetOCRer analyzer(m_image);
analyzer.set_task_info("RoguelikeRecruitOcrFlag", "RoguelikeRecruitOcr");
analyzer.set_replace(Task.get("CharsNameOcrReplace")->replace_map,
Task.get("CharsNameOcrReplace")->replace_full);
@@ -68,7 +68,7 @@ int asst::RoguelikeRecruitImageAnalyzer::match_elite(const Rect& raw_roi)
double max_score = 0;
for (const auto& [task_name, elite] : EliteTaskName) {
- MatchImageAnalyzer analyzer(m_image);
+ Matcher analyzer(m_image);
auto task_ptr = Task.get(task_name);
analyzer.set_task_info(task_ptr);
analyzer.set_roi(raw_roi.move(task_ptr->rect_move));
@@ -89,7 +89,7 @@ int asst::RoguelikeRecruitImageAnalyzer::match_level(const cv::Mat& image, const
{
LogTraceFunction;
- OcrWithPreprocessImageAnalyzer analyzer(image);
+ RegionOCRer analyzer(image);
analyzer.set_task_info("NumberOcrReplace");
analyzer.set_roi(raw_roi.move(Task.get("RoguelikeRecruitLevel")->rect_move));
analyzer.set_bin_expansion(1);
diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.h b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.h
index 08fddb6559..be657c7f01 100644
--- a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.h
+++ b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.h
@@ -1,14 +1,14 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
#include "Common/AsstBattleDef.h"
namespace asst
{
- class RoguelikeRecruitImageAnalyzer final : public AbstractImageAnalyzer
+ class RoguelikeRecruitImageAnalyzer final : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~RoguelikeRecruitImageAnalyzer() noexcept override = default;
bool analyze();
diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.cpp b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.cpp
index bb11cd49e6..7163d78035 100644
--- a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.cpp
+++ b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.cpp
@@ -8,10 +8,10 @@
#include "Controller/Controller.h"
#include "Utils/Logger.hpp"
#include "Utils/NoWarningCV.h"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/OcrImageAnalyzer.h"
-#include "Vision/OcrWithFlagTemplImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/OCRer.h"
+#include "Vision/TemplDetOCRer.h"
+#include "Vision/RegionOCRer.h"
bool asst::RoguelikeRecruitSupportAnalyzer::analyze()
{
@@ -19,7 +19,7 @@ bool asst::RoguelikeRecruitSupportAnalyzer::analyze()
if (m_mode == battle::roguelike::SupportAnalyzeMode::ChooseSupportBtn) {
// 识别“选择助战”
- OcrImageAnalyzer analyzer(m_image);
+ OCRer analyzer(m_image);
const auto& task = Task.get("RoguelikeChooseSupportBtnOcr");
analyzer.set_roi(task->roi);
analyzer.set_required(task->text);
@@ -30,7 +30,7 @@ bool asst::RoguelikeRecruitSupportAnalyzer::analyze()
}
else if (m_mode == battle::roguelike::SupportAnalyzeMode::AnalyzeChars) {
// 识别干员
- OcrImageAnalyzer analyzer(m_image);
+ OCRer analyzer(m_image);
analyzer.set_roi(Task.get("RoguelikeRecruitSupportOcr")->roi);
analyzer.set_required(m_required);
analyzer.set_replace(Task.get("CharsNameOcrReplace")->replace_map,
@@ -93,7 +93,7 @@ bool asst::RoguelikeRecruitSupportAnalyzer::analyze()
}
else if (m_mode == battle::roguelike::SupportAnalyzeMode::RefreshSupportBtn) {
// 识别“更新助战列表”
- OcrImageAnalyzer analyzer(m_image);
+ OCRer analyzer(m_image);
// 未处在冷却时间
analyzer.set_task_info("RoguelikeRefreshSupportBtnOcr");
@@ -147,7 +147,7 @@ int asst::RoguelikeRecruitSupportAnalyzer::match_elite(const Rect& roi, const in
cv::threshold(m_image, bin_img, threshold, 255, cv::THRESH_BINARY);
for (const auto& [task_name, elite] : EliteTaskName) {
- MatchImageAnalyzer analyzer(bin_img);
+ Matcher analyzer(bin_img);
auto task_ptr = Task.get(task_name);
analyzer.set_task_info(task_ptr);
analyzer.set_roi(roi);
@@ -190,7 +190,7 @@ int asst::RoguelikeRecruitSupportAnalyzer::match_level(const Rect& roi)
{
LogTraceFunction;
- OcrWithPreprocessImageAnalyzer analyzer(m_image);
+ RegionOCRer analyzer(m_image);
analyzer.set_task_info("NumberOcrReplace");
analyzer.set_roi(roi);
analyzer.set_bin_expansion(1);
diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.h b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.h
index 877c04957a..9695bf8e33 100644
--- a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.h
+++ b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.h
@@ -1,14 +1,14 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
#include "Common/AsstBattleDef.h"
namespace asst
{
- class RoguelikeRecruitSupportAnalyzer final : public AbstractImageAnalyzer
+ class RoguelikeRecruitSupportAnalyzer final : public VisionHelper
{
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~RoguelikeRecruitSupportAnalyzer() noexcept override = default;
bool analyze();
diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeSkillSelectionImageAnalyzer.cpp b/src/MaaCore/Vision/Roguelike/RoguelikeSkillSelectionImageAnalyzer.cpp
index 00b77640ab..b9072b3d9c 100644
--- a/src/MaaCore/Vision/Roguelike/RoguelikeSkillSelectionImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/Roguelike/RoguelikeSkillSelectionImageAnalyzer.cpp
@@ -6,13 +6,13 @@
#include "Config/TaskData.h"
#include "Utils/Logger.hpp"
#include "Utils/StringMisc.hpp"
-#include "Vision/MatchImageAnalyzer.h"
-#include "Vision/MultiMatchImageAnalyzer.h"
-#include "Vision/OcrWithPreprocessImageAnalyzer.h"
+#include "Vision/Matcher.h"
+#include "Vision/MultiMatcher.h"
+#include "Vision/RegionOCRer.h"
bool asst::RoguelikeSkillSelectionImageAnalyzer::analyze()
{
- MultiMatchImageAnalyzer flag_analyzer(m_image);
+ MultiMatcher flag_analyzer(m_image);
flag_analyzer.set_task_info("RoguelikeSkillSelectionFlag");
if (!flag_analyzer.analyze()) {
@@ -48,7 +48,7 @@ bool asst::RoguelikeSkillSelectionImageAnalyzer::analyze()
std::string asst::RoguelikeSkillSelectionImageAnalyzer::name_analyze(const Rect& roi)
{
- OcrWithPreprocessImageAnalyzer analyzer;
+ RegionOCRer analyzer;
auto name_task_ptr = Task.get("RoguelikeSkillSelectionName");
analyzer.set_bin_threshold(name_task_ptr->specific_rect.x);
analyzer.set_task_info(name_task_ptr);
@@ -81,7 +81,7 @@ std::vector asst::RoguelikeSkillSelectionImageAnalyzer::skill_analyz
void asst::RoguelikeSkillSelectionImageAnalyzer::team_full_analyze()
{
- MatchImageAnalyzer analyzer(m_image);
+ Matcher analyzer(m_image);
analyzer.set_task_info("RoguelikeSkillSelectionTeamFull");
m_team_full = !analyzer.analyze();
}
diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeSkillSelectionImageAnalyzer.h b/src/MaaCore/Vision/Roguelike/RoguelikeSkillSelectionImageAnalyzer.h
index bbaafe64f7..e48ed51b79 100644
--- a/src/MaaCore/Vision/Roguelike/RoguelikeSkillSelectionImageAnalyzer.h
+++ b/src/MaaCore/Vision/Roguelike/RoguelikeSkillSelectionImageAnalyzer.h
@@ -1,15 +1,15 @@
#pragma once
-#include "Vision/AbstractImageAnalyzer.h"
+#include "Vision/VisionHelper.h"
namespace asst
{
- class RoguelikeSkillSelectionImageAnalyzer final : public AbstractImageAnalyzer
+ class RoguelikeSkillSelectionImageAnalyzer final : public VisionHelper
{
public:
static constexpr size_t MaxNumOfSkills = 3;
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
+ using VisionHelper::VisionHelper;
virtual ~RoguelikeSkillSelectionImageAnalyzer() override = default;
bool analyze();
@@ -19,7 +19,7 @@ namespace asst
private:
// 该分析器不支持外部设置ROI
- using AbstractImageAnalyzer::set_roi;
+ using VisionHelper::set_roi;
std::string name_analyze(const Rect& roi);
std::vector skill_analyze(const Rect& roi);
diff --git a/src/MaaCore/Vision/OcrWithFlagTemplImageAnalyzer.cpp b/src/MaaCore/Vision/TemplDetOCRer.cpp
similarity index 70%
rename from src/MaaCore/Vision/OcrWithFlagTemplImageAnalyzer.cpp
rename to src/MaaCore/Vision/TemplDetOCRer.cpp
index 34d37bde52..20f0e103b8 100644
--- a/src/MaaCore/Vision/OcrWithFlagTemplImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/TemplDetOCRer.cpp
@@ -1,14 +1,14 @@
-#include "OcrWithFlagTemplImageAnalyzer.h"
+#include "TemplDetOCRer.h"
#include "Config/TaskData.h"
-#include "MultiMatchImageAnalyzer.h"
-#include "OcrWithPreprocessImageAnalyzer.h"
+#include "MultiMatcher.h"
+#include "RegionOCRer.h"
using namespace asst;
-OcrWithFlagTemplImageAnalyzer::ResultsVecOpt OcrWithFlagTemplImageAnalyzer::analyze() const
+TemplDetOCRer::ResultsVecOpt TemplDetOCRer::analyze() const
{
- MultiMatchImageAnalyzer flag_analyzer(m_image, m_roi);
+ MultiMatcher flag_analyzer(m_image, m_roi);
flag_analyzer.set_params(MatcherConfig::m_params);
auto matched_vec_opt = flag_analyzer.analyze();
@@ -21,7 +21,7 @@ OcrWithFlagTemplImageAnalyzer::ResultsVecOpt OcrWithFlagTemplImageAnalyzer::anal
for (const auto& matched : matched_vec) {
Rect roi = matched.rect.move(m_flag_rect_move);
- OcrWithPreprocessImageAnalyzer ocr_analyzer(m_image, roi);
+ RegionOCRer ocr_analyzer(m_image, roi);
ocr_analyzer.set_params(OCRerConfig::m_params);
auto ocr_opt = ocr_analyzer.analyze();
if (!ocr_opt) {
@@ -45,7 +45,7 @@ OcrWithFlagTemplImageAnalyzer::ResultsVecOpt OcrWithFlagTemplImageAnalyzer::anal
return m_result;
}
-void OcrWithFlagTemplImageAnalyzer::set_task_info(const std::string& templ_task_name, const std::string& ocr_task_name)
+void TemplDetOCRer::set_task_info(const std::string& templ_task_name, const std::string& ocr_task_name)
{
auto match_task_ptr = Task.get(templ_task_name);
m_roi = match_task_ptr->roi;
@@ -56,7 +56,7 @@ void OcrWithFlagTemplImageAnalyzer::set_task_info(const std::string& templ_task_
OCRerConfig::_set_task_info(*ocr_task_ptr);
}
-void OcrWithFlagTemplImageAnalyzer::set_flag_rect_move(Rect flag_rect_move)
+void TemplDetOCRer::set_flag_rect_move(Rect flag_rect_move)
{
m_flag_rect_move = flag_rect_move;
}
diff --git a/src/MaaCore/Vision/OcrWithFlagTemplImageAnalyzer.h b/src/MaaCore/Vision/TemplDetOCRer.h
similarity index 81%
rename from src/MaaCore/Vision/OcrWithFlagTemplImageAnalyzer.h
rename to src/MaaCore/Vision/TemplDetOCRer.h
index bccb949669..87080ed21b 100644
--- a/src/MaaCore/Vision/OcrWithFlagTemplImageAnalyzer.h
+++ b/src/MaaCore/Vision/TemplDetOCRer.h
@@ -1,11 +1,11 @@
#pragma once
-#include "AbstractImageAnalyzer.h"
#include "Config/MatcherConfig.h"
#include "Config/OCRerConfig.h"
+#include "VisionHelper.h"
namespace asst
{
- class OcrWithFlagTemplImageAnalyzer : public AbstractImageAnalyzer, public OCRerConfig, public MatcherConfig
+ class TemplDetOCRer : public VisionHelper, public OCRerConfig, public MatcherConfig
{
public:
struct Result : public TextRect
@@ -18,8 +18,8 @@ namespace asst
using ResultsVecOpt = std::optional;
public:
- using AbstractImageAnalyzer::AbstractImageAnalyzer;
- virtual ~OcrWithFlagTemplImageAnalyzer() override = default;
+ using VisionHelper::VisionHelper;
+ virtual ~TemplDetOCRer() override = default;
void set_task_info(const std::string& templ_task_name, const std::string& ocr_task_name);
void set_flag_rect_move(Rect flag_rect_move);
diff --git a/src/MaaCore/Vision/AbstractImageAnalyzer.cpp b/src/MaaCore/Vision/VisionHelper.cpp
similarity index 81%
rename from src/MaaCore/Vision/AbstractImageAnalyzer.cpp
rename to src/MaaCore/Vision/VisionHelper.cpp
index d5816ab062..0986f19c16 100644
--- a/src/MaaCore/Vision/AbstractImageAnalyzer.cpp
+++ b/src/MaaCore/Vision/VisionHelper.cpp
@@ -1,4 +1,4 @@
-#include "AbstractImageAnalyzer.h"
+#include "VisionHelper.h"
#include "Utils/NoWarningCV.h"
@@ -11,7 +11,7 @@
using namespace asst;
-AbstractImageAnalyzer::AbstractImageAnalyzer(const cv::Mat& image, const Rect& roi, Assistant* inst)
+VisionHelper::VisionHelper(const cv::Mat& image, const Rect& roi, Assistant* inst)
: InstHelper(inst), m_image(image), m_roi(correct_rect(roi, image))
#ifdef ASST_DEBUG
,
@@ -19,7 +19,7 @@ AbstractImageAnalyzer::AbstractImageAnalyzer(const cv::Mat& image, const Rect& r
#endif
{}
-void AbstractImageAnalyzer::set_image(const cv::Mat& image)
+void VisionHelper::set_image(const cv::Mat& image)
{
m_image = image;
#ifdef ASST_DEBUG
@@ -29,17 +29,17 @@ void AbstractImageAnalyzer::set_image(const cv::Mat& image)
set_roi(m_roi);
}
-void AbstractImageAnalyzer::set_roi(const Rect& roi)
+void VisionHelper::set_roi(const Rect& roi)
{
m_roi = correct_rect(roi, m_image);
}
-void AbstractImageAnalyzer::set_log_tracing(bool enable)
+void VisionHelper::set_log_tracing(bool enable)
{
m_log_tracing = enable;
}
-Rect AbstractImageAnalyzer::correct_rect(const Rect& rect, const cv::Mat& image)
+Rect VisionHelper::correct_rect(const Rect& rect, const cv::Mat& image)
{
if (image.empty()) {
Log.error(__FUNCTION__, "image is empty");
@@ -78,7 +78,7 @@ Rect AbstractImageAnalyzer::correct_rect(const Rect& rect, const cv::Mat& image)
return res;
}
-bool AbstractImageAnalyzer::save_img(const std::filesystem::path& relative_dir)
+bool VisionHelper::save_img(const std::filesystem::path& relative_dir)
{
std::string stem = utils::get_time_filestem();
auto relative_path = relative_dir / (stem + "_raw.png");
diff --git a/src/MaaCore/Vision/AbstractImageAnalyzer.h b/src/MaaCore/Vision/VisionHelper.h
similarity index 92%
rename from src/MaaCore/Vision/AbstractImageAnalyzer.h
rename to src/MaaCore/Vision/VisionHelper.h
index 6f491c83d4..8a19518088 100644
--- a/src/MaaCore/Vision/AbstractImageAnalyzer.h
+++ b/src/MaaCore/Vision/VisionHelper.h
@@ -19,12 +19,12 @@ namespace asst
namespace asst
{
- class AbstractImageAnalyzer : protected InstHelper
+ class VisionHelper : protected InstHelper
{
public:
- AbstractImageAnalyzer() = default;
- AbstractImageAnalyzer(const cv::Mat& image, const Rect& roi = Rect(), Assistant* inst = nullptr);
- virtual ~AbstractImageAnalyzer() = default;
+ VisionHelper() = default;
+ VisionHelper(const cv::Mat& image, const Rect& roi = Rect(), Assistant* inst = nullptr);
+ virtual ~VisionHelper() = default;
virtual void set_image(const cv::Mat& image);
virtual void set_roi(const Rect& roi);