From b0462076ea1842e156c9dcf0b9c4d523baec0580 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Fri, 11 Jul 2025 19:21:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E9=81=87=E5=88=B0=20inf=20=E4=B8=8E=20nan=20?= =?UTF-8?q?=E6=97=B6=E8=BF=94=E5=9B=9E=200=20=E7=9A=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaCore/Vision/Matcher.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/MaaCore/Vision/Matcher.cpp b/src/MaaCore/Vision/Matcher.cpp index 9c897d3458..b6773be021 100644 --- a/src/MaaCore/Vision/Matcher.cpp +++ b/src/MaaCore/Vision/Matcher.cpp @@ -21,12 +21,11 @@ Matcher::ResultOpt Matcher::analyze() const double min_val = 0.0, max_val = 0.0; cv::Point min_loc, max_loc; - cv::minMaxLoc(matched, &min_val, &max_val, &min_loc, &max_loc); + cv::Mat valid_mask; + cv::inRange(matched, 0.0f, 1.0f + 1e-5f, valid_mask); + cv::minMaxLoc(matched, &min_val, &max_val, &min_loc, &max_loc, valid_mask); Rect rect(max_loc.x + m_roi.x, max_loc.y + m_roi.y, templ.cols, templ.rows); - if (std::isnan(max_val) || std::isinf(max_val)) { - max_val = 0; - } double threshold = m_params.templ_thres[i]; if (m_log_tracing && max_val > 0.5 && max_val > threshold - 0.2) { // 得分太低的肯定不对,没必要打印