feat: 给 OcrTaskInfo 加一个 without_det,默认 false;进入关卡前的关卡名识别不使用检测模型

This commit is contained in:
zzyyyl
2022-11-03 22:44:48 +08:00
committed by zzyyyl
parent 413ae17f21
commit adc2a3e623
6 changed files with 12 additions and 0 deletions

View File

@@ -148,6 +148,7 @@
"fullMatch": true,
"isAscii": true,
"cache": false,
"withoutDet": true,
"text": [],
"roi": [
920,

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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",

View File

@@ -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之后再进行匹配
};