From ef9d458b23ed28f019e8349e6beb8a177cc1786c Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Tue, 3 Jun 2025 13:58:23 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=89=B9=E5=BE=81=E5=8C=B9=E9=85=8DASS?= =?UTF-8?q?T=5FDEBUG=E5=A2=9E=E5=8A=A0=E5=8C=B9=E9=85=8D=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E7=BB=98=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaCore/Vision/FeatureMatcher.cpp | 28 +++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/MaaCore/Vision/FeatureMatcher.cpp b/src/MaaCore/Vision/FeatureMatcher.cpp index 0852d2579c..2fd8499dc4 100644 --- a/src/MaaCore/Vision/FeatureMatcher.cpp +++ b/src/MaaCore/Vision/FeatureMatcher.cpp @@ -48,18 +48,34 @@ asst::FeatureMatcher::ResultsVecOpt asst::FeatureMatcher::analyze() const auto [keypoints_1, descriptors_1] = detect(templ, create_mask(templ, m_params.green_mask)); auto results = feature_match(templ, keypoints_1, descriptors_1); +#ifdef ASST_DEBUG + const auto& color = cv::Scalar(0, 0, 255); +#endif + for (const auto& r : results) { + if (r.count < m_params.count) { + Log.debug("feature_match |", templ_name, "count:", r.count, "rect:", r.rect, "roi:", m_roi); + } + else { + Log.trace("feature_match |", templ_name, "count:", r.count, "rect:", r.rect, "roi:", m_roi); + } +#ifdef ASST_DEBUG + cv::putText( + m_image_draw, + "count: " + std::to_string(r.count), + cv::Point(r.rect.x, r.rect.y - 5), + cv::FONT_HERSHEY_PLAIN, + 1.2, + color, + 1); + cv::rectangle(m_image_draw, make_rect(r.rect), cv::Scalar(0, 0, 255), 2); +#endif + } std::erase_if(results, [&](const auto& res) { return res.count < m_params.count; }); auto cost = std::chrono::duration_cast(std::chrono::steady_clock::now() - start_time); if (results.empty()) { return std::nullopt; } - for (const auto& r : results) { - Log.trace("feature_match |", templ_name, "count:", r.count, "rect:", r.rect, "roi:", m_roi); -#ifdef ASST_DEBUG - cv::rectangle(m_image_draw, make_rect(r.rect), cv::Scalar(0, 0, 255), 2); -#endif - } Log.trace("count:", results.size(), ", cost:", cost.count(), "ms"); m_result = std::move(results); return m_result;