跳到主要内容

MatchResult:getScore()

返回匹配的置信度分数。

描述

getScore() 方法返回一个十进制数值,表示找到的区域与搜索模板的匹配程度。分数越高,表示匹配越好。

  • 对于图像匹配,分数通常在 0.01.0 之间,其中 1.0 表示完美匹配。
  • 默认的匹配阈值通常约为 0.8(80% 置信度)。

这对于根据匹配质量筛选结果或用于调试目的非常有用。

签名

getScore(): number

返回值

number - 匹配的置信度分数(通常在 0.0 到 1.0 之间)。

示例

local result = Screen:find("template.png")
if result then
local score = result:getScore()
toast("Match confidence: " .. (score * 100) .. "%")
-- 仅在置信度足够高时才继续
if score >= 0.9 then
toast("High confidence match found!")
end
end