diff --git a/src/MeoAssistance/AsstDef.h b/src/MeoAssistance/AsstDef.h index 69f7469f2c..24466c1eec 100644 --- a/src/MeoAssistance/AsstDef.h +++ b/src/MeoAssistance/AsstDef.h @@ -76,6 +76,13 @@ namespace asst { { return x == rhs.x && y == rhs.y && width == rhs.width && height == rhs.height; } + bool include(const Rect& rhs) const noexcept + { + return x <= rhs.x + && y <= rhs.y + && (x + width) >= (rhs.x + rhs.width) + && (y + height) >= (rhs.y + rhs.height); + } int x = 0; int y = 0; diff --git a/src/MeoAssistance/ProcessTask.cpp b/src/MeoAssistance/ProcessTask.cpp index b68163b390..475e35871d 100644 --- a/src/MeoAssistance/ProcessTask.cpp +++ b/src/MeoAssistance/ProcessTask.cpp @@ -162,20 +162,21 @@ std::shared_ptr ProcessTask::match_image(Rect* matched_rect) break; case AlgorithmType::MatchTemplate: { - std::shared_ptr process_task_info_ptr = + std::shared_ptr match_task_info_ptr = std::dynamic_pointer_cast(task_info_ptr); - double templ_threshold = process_task_info_ptr->templ_threshold; - double hist_threshold = process_task_info_ptr->hist_threshold; - double add_cache_thres = process_task_info_ptr->cache ? templ_threshold : Identify::NotAddCache; + double templ_threshold = match_task_info_ptr->templ_threshold; + double hist_threshold = match_task_info_ptr->hist_threshold; + double add_cache_thres = match_task_info_ptr->cache ? templ_threshold : Identify::NotAddCache; cv::Mat identify_image; - const auto& identify_area = m_controller_ptr->shaped_correct(task_info_ptr->identify_area); + const auto& identify_area = m_controller_ptr->shaped_correct(match_task_info_ptr->identify_area); if (identify_area.width == 0) { identify_image = cur_image; } else { identify_image = cur_image(make_rect(identify_area)); } - auto&& [algorithm, score, temp_rect] = m_identify_ptr->find_image(identify_image, task_name, add_cache_thres); + auto&& [algorithm, score, temp_rect] = + m_identify_ptr->find_image(identify_image, task_name, add_cache_thres); rect = std::move(temp_rect); rect.x += identify_area.x; rect.y += identify_area.y; @@ -206,84 +207,90 @@ std::shared_ptr ProcessTask::match_image(Rect* matched_rect) std::dynamic_pointer_cast(task_info_ptr); std::vector