mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
@@ -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<cv::Rect>(m_roi));
|
||||
if (templ.cols > image_roi.cols || templ.rows > image_roi.rows) {
|
||||
Log.error("templ size is too large", m_templ_name,
|
||||
|
||||
@@ -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<cv::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<cv::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<int>(m_difficulty));
|
||||
|
||||
#ifdef ASST_DEBUG
|
||||
cv::rectangle(m_image_draw, utils::make_rect<cv::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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user