mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 10:57:45 +08:00
feat: 给 OcrTaskInfo 加一个 without_det,默认 false;进入关卡前的关卡名识别不使用检测模型
This commit is contained in:
@@ -148,6 +148,7 @@
|
||||
"fullMatch": true,
|
||||
"isAscii": true,
|
||||
"cache": false,
|
||||
"withoutDet": true,
|
||||
"text": [],
|
||||
"roi": [
|
||||
920,
|
||||
|
||||
@@ -91,6 +91,11 @@ void asst::OcrImageAnalyzer::set_use_cache(bool is_use) noexcept
|
||||
m_use_cache = is_use;
|
||||
}
|
||||
|
||||
void asst::OcrImageAnalyzer::set_without_det(bool without_det) noexcept
|
||||
{
|
||||
m_without_det = without_det;
|
||||
}
|
||||
|
||||
void asst::OcrImageAnalyzer::set_required(std::vector<std::string> required) noexcept
|
||||
{
|
||||
m_required = std::move(required);
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace asst
|
||||
virtual void set_task_info(const std::string& task_name);
|
||||
|
||||
virtual void set_use_cache(bool is_use) noexcept;
|
||||
virtual void set_without_det(bool without_det) noexcept;
|
||||
virtual void set_region_of_appeared(Rect region) noexcept;
|
||||
virtual void set_use_char_model(bool enable) noexcept;
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ bool asst::ProcessTaskImageAnalyzer::ocr_analyze(const std::shared_ptr<TaskInfo>
|
||||
m_ocr_analyzer = std::make_unique<OcrImageAnalyzer>(m_image);
|
||||
}
|
||||
m_ocr_analyzer->set_region_of_appeared(Rect());
|
||||
m_ocr_analyzer->set_without_det(ocr_task_ptr->without_det);
|
||||
m_ocr_analyzer->set_task_info(ocr_task_ptr);
|
||||
m_ocr_analyzer->set_use_char_model(ocr_task_ptr->is_ascii);
|
||||
auto region_opt = m_status->get_rect(ocr_task_ptr->name);
|
||||
|
||||
@@ -344,6 +344,7 @@ asst::TaskData::taskptr_t asst::TaskData::generate_ocr_task_info([[maybe_unused]
|
||||
|
||||
ocr_task_info_ptr->full_match = task_json.get("fullMatch", default_ptr->full_match);
|
||||
ocr_task_info_ptr->is_ascii = task_json.get("isAscii", default_ptr->is_ascii);
|
||||
ocr_task_info_ptr->without_det = task_json.get("withoutDet", default_ptr->without_det);
|
||||
if (auto opt = task_json.find<json::array>("ocrReplace")) {
|
||||
for (const json::value& rep : opt.value()) {
|
||||
ocr_task_info_ptr->replace_map.emplace(rep[0].as_string(), rep[1].as_string());
|
||||
@@ -482,6 +483,7 @@ std::shared_ptr<asst::OcrTaskInfo> asst::TaskData::_default_ocr_task_info()
|
||||
auto ocr_task_info_ptr = std::make_shared<OcrTaskInfo>();
|
||||
ocr_task_info_ptr->full_match = false;
|
||||
ocr_task_info_ptr->is_ascii = false;
|
||||
ocr_task_info_ptr->without_det = false;
|
||||
|
||||
return ocr_task_info_ptr;
|
||||
}
|
||||
@@ -555,6 +557,7 @@ bool asst::TaskData::syntax_check(const std::string& task_name, const json::valu
|
||||
"sub",
|
||||
"subErrorIgnored",
|
||||
"isAscii",
|
||||
"withoutDet",
|
||||
"next",
|
||||
"maxTimes",
|
||||
"exceededNext",
|
||||
|
||||
@@ -360,6 +360,7 @@ namespace asst
|
||||
std::vector<std::string> text; // 文字的容器,匹配到这里面任一个,就算匹配上了
|
||||
bool full_match = false; // 是否需要全匹配,否则搜索到子串就算匹配上了
|
||||
bool is_ascii = false; // 是否启用字符数字模型
|
||||
bool without_det = false; // 是否不使用检测模型
|
||||
std::unordered_map<std::string, std::string>
|
||||
replace_map; // 部分文字容易识别错,字符串强制replace之后,再进行匹配
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user