Compare commits

...

2 Commits

Author SHA1 Message Date
status102
5e504ac35f feat: 干员精英, 等级, 技能等级1-7识别 2026-05-12 18:49:25 +08:00
status102
c844d26ec0 rft: OperBox 相关Analyzer迁移 2026-05-12 14:50:34 +08:00
15 changed files with 134 additions and 6 deletions

View File

@@ -4384,6 +4384,19 @@
"text": [],
"roi": [5, 230, 37, 23]
},
"OperDetailElite": {
"template": ["OperDetail-Elite2.png", "OperDetail-Elite1.png", "OperDetail-Elite0.png"],
"roi": [860, 240, 120, 80]
},
"OperDetailLevel": {
"baseTask": "NumberOcrReplace",
"roi": [885, 115, 90, 55]
},
"OperDetailSkillLevel-Base": {
"baseTask": "NumberOcrReplace",
"doc": "4星以上才有专精",
"roi": [1214, 355, 16, 22]
},
"OperParadoxBegin": {
"algorithm": "JustReturn",
"next": ["OperOpenInformationMenu"],

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -16,8 +16,8 @@
#include "Vision/Battle/BattlefieldClassifier.h"
#include "Vision/Battle/BattlefieldMatcher.h"
#include "Vision/Matcher.h"
#include "Vision/Miscellaneous/OperNameAnalyzer.h"
#include "Vision/MultiMatcher.h"
#include "Vision/Oper/OperNameAnalyzer.h"
#include "Vision/RegionOCRer.h"
#include <ranges>

View File

@@ -13,9 +13,9 @@
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
#include "Vision/Matcher.h"
#include "Vision/Miscellaneous/OperNameAnalyzer.h"
#include "Vision/Miscellaneous/PipelineAnalyzer.h"
#include "Vision/MultiMatcher.h"
#include "Vision/Oper/OperNameAnalyzer.h"
#include "Vision/RegionOCRer.h"
asst::BattleFormationTask::BattleFormationTask(

View File

@@ -8,7 +8,7 @@
#include "Controller/Controller.h"
#include "Task/ProcessTask.h"
#include "Utils/Logger.hpp"
#include "Vision/Miscellaneous/OperBoxImageAnalyzer.h"
#include "Vision/Oper/OperBoxImageAnalyzer.h"
#include "Vision/TemplDetOCRer.h"
bool asst::OperBoxRecognitionTask::_run()

View File

@@ -1,7 +1,7 @@
#pragma once
#include "Common/AsstBattleDef.h"
#include "Task/AbstractTask.h"
#include "Vision/Miscellaneous/OperBoxImageAnalyzer.h"
#include "Vision/Oper/OperBoxImageAnalyzer.h"
namespace asst
{

View File

@@ -2,7 +2,7 @@
#include "Task/AbstractTask.h"
#include "Common/AsstBattleDef.h"
#include "Vision/Miscellaneous/OperBoxImageAnalyzer.h"
#include "Vision/Oper/OperBoxImageAnalyzer.h"
namespace asst
{

View File

@@ -0,0 +1,80 @@
#include "OperDetailPage.h"
#include "Config/TaskData.h"
#include "Controller/Controller.h"
#include "MaaUtils/NoWarningCV.hpp"
#include "Task/ProcessTask.h"
#include "Utils/DebugImageHelper.hpp"
#include "Utils/Logger.hpp"
#include "Vision/Matcher.h"
#include "Vision/MultiMatcher.h"
#include "Vision/RegionOCRer.h"
asst::OperDetailPage::OperDetailPage(
const AsstCallback& callback,
Assistant* inst,
std::string_view task_chain) :
InstHelper(inst),
m_callback(callback),
m_task_chain(task_chain)
{
}
std::optional<int> asst::OperDetailPage::analyze_elite(const cv::Mat& image)
{
const static auto& elite_task = Task.get("OperDetailElite");
Matcher matcher(image);
matcher.set_task_info(elite_task);
if (!matcher.analyze()) {
LogError << __FUNCTION__ << "analyze elite failed";
return std::nullopt;
}
int elite = 0;
auto length = matcher.get_result().templ_name.size();
auto elite_str = matcher.get_result().templ_name.substr(length - 1);
if (elite_str.empty() || !utils::chars_to_number(elite_str, elite)) {
LogError << __FUNCTION__ << "convert elite failed, template:" << matcher.get_result().templ_name
<< ", str:" << elite_str;
return std::nullopt;
}
return elite;
}
std::optional<int> asst::OperDetailPage::analyze_level(const cv::Mat& image)
{
const static auto& level_task = Task.get("OperDetailLevel");
RegionOCRer ocrer(image);
ocrer.set_task_info(level_task);
if (!ocrer.analyze()) {
LogError << __FUNCTION__ << "ocr oper level failed, str:" << ocrer.get_result().text;
return std::nullopt;
}
int level = 0;
if (!utils::chars_to_number(ocrer.get_result().text, level)) {
LogError << __FUNCTION__ << "convert oper level failed, str:" << ocrer.get_result().text;
return std::nullopt;
}
return level;
}
std::optional<int> asst::OperDetailPage::analyze_skill_level(const cv::Mat& image)
{
const static auto& level_base = Task.get("OperDetailSkillLevel-Base");
RegionOCRer ocrer(image);
ocrer.set_task_info(level_base);
if (!ocrer.analyze()) {
LogError << __FUNCTION__ << "ocr skill level base failed, str:" << ocrer.get_result().text;
return std::nullopt;
}
int base_level = 0;
if (!utils::chars_to_number(ocrer.get_result().text, base_level)) {
LogError << __FUNCTION__ << "convert skill level base failed, str:" << ocrer.get_result().text;
return std::nullopt;
}
return base_level;
}

View File

@@ -0,0 +1,35 @@
#pragma once
#include <optional>
#include "Common/AsstMsg.h"
#include "Common/AsstTypes.h"
#include "InstHelper.h"
#include "MaaUtils/NoWarningCV.hpp"
namespace asst
{
class OperDetailPage : private InstHelper
{
public:
struct SkillResult
{
Rect rect;
int level = -1;
};
public:
OperDetailPage(const AsstCallback& callback, Assistant* inst, std::string_view task_chain);
virtual ~OperDetailPage() = default;
private:
// 用于创建 ProcessTask
AsstCallback m_callback = nullptr;
std::string_view m_task_chain;
public:
std::optional<int> analyze_elite(const cv::Mat& image);
std::optional<int> analyze_level(const cv::Mat& image);
std::optional<int> analyze_skill_level(const cv::Mat& image);
};
} // namespace asst

View File

@@ -8,8 +8,8 @@
#include "Utils/Logger.hpp"
#include "Vision/BestMatcher.h"
#include "Vision/Matcher.h"
#include "Vision/Miscellaneous/OperNameAnalyzer.h"
#include "Vision/MultiMatcher.h"
#include "Vision/Oper/OperNameAnalyzer.h"
#include "Vision/RegionOCRer.h"
#include "Vision/TemplDetOCRer.h"