diff --git a/src/MeoAssistant/MatchImageAnalyzer.cpp b/src/MeoAssistant/MatchImageAnalyzer.cpp index 34398cf3b1..cb8bdf529d 100644 --- a/src/MeoAssistant/MatchImageAnalyzer.cpp +++ b/src/MeoAssistant/MatchImageAnalyzer.cpp @@ -100,6 +100,25 @@ bool asst::MatchImageAnalyzer::match_templ(const cv::Mat templ) { cv::Mat matched; + Log.trace(__FUNCTION__, "raw_roi", m_roi.to_string()); + + if (m_roi.x < 0) { + Log.info(__FUNCTION__, "roi is out of range"); + m_roi.x = 0; + } + if (m_roi.y < 0) { + Log.info(__FUNCTION__, "roi is out of range"); + m_roi.y = 0; + } + if (m_roi.x + m_roi.width >= m_image.cols) { + Log.info(__FUNCTION__, "roi is out of range"); + m_roi.width = m_image.cols - m_roi.x; + } + if (m_roi.y + m_roi.height >= m_image.rows) { + Log.info(__FUNCTION__, "roi is out of range"); + m_roi.height = m_image.rows - m_roi.y; + } + cv::Mat image_roi = m_image(utils::make_rect(m_roi)); if (templ.cols > image_roi.cols || templ.rows > image_roi.rows) { Log.error("templ size is too large", m_templ_name, diff --git a/src/MeoAssistant/StageDropsImageAnalyzer.cpp b/src/MeoAssistant/StageDropsImageAnalyzer.cpp index fcfa347aba..e17b4c85f7 100644 --- a/src/MeoAssistant/StageDropsImageAnalyzer.cpp +++ b/src/MeoAssistant/StageDropsImageAnalyzer.cpp @@ -60,6 +60,8 @@ bool asst::StageDropsImageAnalyzer::analyze_stage_code() } m_stage_code = analyzer.get_result().front().text; + Log.info(__FUNCTION__, "stage_code", m_stage_code); + #ifdef ASST_DEBUG const Rect& text_rect = analyzer.get_result().front().rect; cv::rectangle(m_image_draw, utils::make_rect(text_rect), cv::Scalar(0, 0, 255), 2); @@ -104,6 +106,8 @@ bool asst::StageDropsImageAnalyzer::analyze_stars() } m_stars = matched_stars; + Log.info(__FUNCTION__, "stars", m_stars); + #ifdef ASST_DEBUG cv::rectangle(m_image_draw, utils::make_rect(matched_rect), cv::Scalar(0, 0, 255), 2); cv::putText(m_image_draw, std::to_string(m_stars) + " stars", cv::Point(matched_rect.x, matched_rect.y + matched_rect.height + 20), @@ -150,6 +154,7 @@ bool asst::StageDropsImageAnalyzer::analyze_difficulty() } } m_difficulty = matched; + Log.info(__FUNCTION__, "difficulty", static_cast(m_difficulty)); #ifdef ASST_DEBUG cv::rectangle(m_image_draw, utils::make_rect(matched_rect), cv::Scalar(0, 0, 255), 2); @@ -285,6 +290,10 @@ bool asst::StageDropsImageAnalyzer::analyze_baseline() m_baseline.emplace_back(baseline, match_droptype(baseline)); } } + Log.trace(__FUNCTION__, "baseline size", m_baseline.size()); + for (const auto& baseline : m_baseline) { + Log.trace(__FUNCTION__, "baseline", baseline.first.to_string()); + } return !m_baseline.empty(); }