主题
查找最近坐标点 - FindNearestPos
函数简介
返回离指定坐标点最近的识别结果,用于颜色识别结果及图像识别结果的筛选。
接口名称
FindNearestPosDLL调用
c
long FindNearestPos(long ola, char* json, int type, int x, int y);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| json | 字符串 | 识别结果返回值。 |
| type | 整数型 | 识别类型:1 颜色识别,2 图像识别。 |
| x | 整数型 | 目标点的X坐标。 |
| y | 整数型 | 目标点的Y坐标。 |
输入 JSON 格式
json 参数需传入识别接口返回的 原始 JSON 字符串,格式须与 type 对应:
| type | 来源接口示例 | JSON 格式 |
|---|---|---|
1 颜色识别 | FindColorListEx | [{"X":100,"Y":200},{"X":150,"Y":220}] |
2 图像识别 | FindImageFromPtrAll 等 | [{"MatchVal":0.95,"MatchState":true,"Index":0,"Angle":0,"X":100,"Y":200,"Width":32,"Height":32}] |
SDK 注意:上述识别接口在 SDK 中会将 JSON 自动反序列化 为模型对象(如
Point/MatchResult、Point2D/MatchData等)。调用本接口前须 再序列化回 JSON 字符串,推荐使用 SDK 模型上的ToJSON()/toJSON()方法(列表可逐元素序列化后拼接为 JSON 数组)。原生 DLL 调用则可直接使用识别接口返回的 JSON,无需转换。
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
std::string nearest = ola.FindNearestPos("[{\"MatchVal\":0.95,\"MatchState\":true,\"Index\":0,\"Angle\":0,\"X\":100,\"Y\":200,\"Width\":32,\"Height\":32},{\"MatchVal\":0.88,\"MatchState\":true,\"Index\":1,\"Angle\":0,\"X\":150,\"Y\":220,\"Width\":32,\"Height\":32},{\"MatchVal\":0.80,\"MatchState\":true,\"Index\":2,\"Angle\":0,\"X\":300,\"Y\":100,\"Width\":32,\"Height\":32}]", 2, 120, 210);csharp
using OLAPlug;
var ola = new OLAPlugServer();
string nearest = ola.FindNearestPos(@"[{"MatchVal":0.95,"MatchState":true,"Index":0,"Angle":0,"X":100,"Y":200,"Width":32,"Height":32},{"MatchVal":0.88,"MatchState":true,"Index":1,"Angle":0,"X":150,"Y":220,"Width":32,"Height":32},{"MatchVal":0.80,"MatchState":true,"Index":2,"Angle":0,"X":300,"Y":100,"Width":32,"Height":32}]", 2, 120, 210);python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
nearest = ola.FindNearestPos(r'[{"MatchVal":0.95,"MatchState":true,"Index":0,"Angle":0,"X":100,"Y":200,"Width":32,"Height":32},{"MatchVal":0.88,"MatchState":true,"Index":1,"Angle":0,"X":150,"Y":220,"Width":32,"Height":32},{"MatchVal":0.80,"MatchState":true,"Index":2,"Angle":0,"X":300,"Y":100,"Width":32,"Height":32}]', 2, 120, 210)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
ola.FindNearestPos("[{\"MatchVal\":0.95,\"MatchState\":true,\"Index\":0,\"Angle\":0,\"X\":100,\"Y\":200,\"Width\":32,\"Height\":32},{\"MatchVal\":0.88,\"MatchState\":true,\"Index\":1,\"Angle\":0,\"X\":150,\"Y\":220,\"Width\":32,\"Height\":32},{\"MatchVal\":0.80,\"MatchState\":true,\"Index\":2,\"Angle\":0,\"X\":300,\"Y\":100,\"Width\":32,\"Height\":32}]", 2, 120, 210);go
import "github.com/ola/olaplug/olaplug"
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
nearest := ola.FindNearestPos("[{\"MatchVal\":0.95,\"MatchState\":true,\"Index\":0,\"Angle\":0,\"X\":100,\"Y\":200,\"Width\":32,\"Height\":32},{\"MatchVal\":0.88,\"MatchState\":true,\"Index\":1,\"Angle\":0,\"X\":150,\"Y\":220,\"Width\":32,\"Height\":32},{\"MatchVal\":0.80,\"MatchState\":true,\"Index\":2,\"Angle\":0,\"X\":300,\"Y\":100,\"Width\":32,\"Height\":32}]", 2, 120, 210)rust
use olaplug::OLAPlugServer;
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let nearest = ola.find_nearest_pos("[{\"MatchVal\":0.95, \"MatchState\":true, \"Index\":0, \"Angle\":0, \"X\":100, \"Y\":200, \"Width\":32, \"Height\":32}, {\"MatchVal\":0.88, \"MatchState\":true, \"Index\":1, \"Angle\":0, \"X\":150, \"Y\":220, \"Width\":32, \"Height\":32}, {\"MatchVal\":0.80, \"MatchState\":true, \"Index\":2, \"Angle\":0, \"X\":300, \"Y\":100, \"Width\":32, \"Height\":32}]", 2, 120, 210);cpp
var ola = com("OlaPlug.OlaSoft")
ola.FindNearestPos("[{\"MatchVal\":0.95,\"MatchState\":true,\"Index\":0,\"Angle\":0,\"X\":100,\"Y\":200,\"Width\":32,\"Height\":32},{\"MatchVal\":0.88,\"MatchState\":true,\"Index\":1,\"Angle\":0,\"X\":150,\"Y\":220,\"Width\":32,\"Height\":32},{\"MatchVal\":0.80,\"MatchState\":true,\"Index\":2,\"Angle\":0,\"X\":300,\"Y\":100,\"Width\":32,\"Height\":32}]", 2, 120, 210);vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.FindNearestPos("[{\"MatchVal\":0.95,\"MatchState\":true,\"Index\":0,\"Angle\":0,\"X\":100,\"Y\":200,\"Width\":32,\"Height\":32},{\"MatchVal\":0.88,\"MatchState\":true,\"Index\":1,\"Angle\":0,\"X\":150,\"Y\":220,\"Width\":32,\"Height\":32},{\"MatchVal\":0.80,\"MatchState\":true,\"Index\":2,\"Angle\":0,\"X\":300,\"Y\":100,\"Width\":32,\"Height\":32}]", 2, 120, 210);text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.FindNearestPos(“[{\“MatchVal\“:0.95,\“MatchState\“:true,\“Index\“:0,\“Angle\“:0,\“X\“:100,\“Y\“:200,\“Width\“:32,\“Height\“:32},{\“MatchVal\“:0.88,\“MatchState\“:true,\“Index\“:1,\“Angle\“:0,\“X\“:150,\“Y\“:220,\“Width\“:32,\“Height\“:32},{\“MatchVal\“:0.80,\“MatchState\“:true,\“Index\“:2,\“Angle\“:0,\“X\“:300,\“Y\“:100,\“Width\“:32,\“Height\“:32}]“, 2, 120, 210);aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.FindNearestPos("[{\"MatchVal\":0.95,\"MatchState\":true,\"Index\":0,\"Angle\":0,\"X\":100,\"Y\":200,\"Width\":32,\"Height\":32},{\"MatchVal\":0.88,\"MatchState\":true,\"Index\":1,\"Angle\":0,\"X\":150,\"Y\":220,\"Width\":32,\"Height\":32},{\"MatchVal\":0.80,\"MatchState\":true,\"Index\":2,\"Angle\":0,\"X\":300,\"Y\":100,\"Width\":32,\"Height\":32}]", 2, 120, 210);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.FindNearestPos("[{\"MatchVal\":0.95,\"MatchState\":true,\"Index\":0,\"Angle\":0,\"X\":100,\"Y\":200,\"Width\":32,\"Height\":32},{\"MatchVal\":0.88,\"MatchState\":true,\"Index\":1,\"Angle\":0,\"X\":150,\"Y\":220,\"Width\":32,\"Height\":32},{\"MatchVal\":0.80,\"MatchState\":true,\"Index\":2,\"Angle\":0,\"X\":300,\"Y\":100,\"Width\":32,\"Height\":32}]", 2, 120, 210);cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
ola.FindNearestPos("[{\"MatchVal\":0.95,\"MatchState\":true,\"Index\":0,\"Angle\":0,\"X\":100,\"Y\":200,\"Width\":32,\"Height\":32},{\"MatchVal\":0.88,\"MatchState\":true,\"Index\":1,\"Angle\":0,\"X\":150,\"Y\":220,\"Width\":32,\"Height\":32},{\"MatchVal\":0.80,\"MatchState\":true,\"Index\":2,\"Angle\":0,\"X\":300,\"Y\":100,\"Width\":32,\"Height\":32}]", 2, 120, 210);原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
std::string nearest = FindNearestPos("[{\"MatchVal\":0.95,\"MatchState\":true,\"Index\":0,\"Angle\":0,\"X\":100,\"Y\":200,\"Width\":32,\"Height\":32},{\"MatchVal\":0.88,\"MatchState\":true,\"Index\":1,\"Angle\":0,\"X\":150,\"Y\":220,\"Width\":32,\"Height\":32},{\"MatchVal\":0.80,\"MatchState\":true,\"Index\":2,\"Angle\":0,\"X\":300,\"Y\":100,\"Width\":32,\"Height\":32}]", 2, 120, 210);csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
string nearest = FindNearestPos(@"[{"MatchVal":0.95,"MatchState":true,"Index":0,"Angle":0,"X":100,"Y":200,"Width":32,"Height":32},{"MatchVal":0.88,"MatchState":true,"Index":1,"Angle":0,"X":150,"Y":220,"Width":32,"Height":32},{"MatchVal":0.80,"MatchState":true,"Index":2,"Angle":0,"X":300,"Y":100,"Width":32,"Height":32}]", 2, 120, 210);python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
nearest = ola.FindNearestPos(r'[{"MatchVal":0.95,"MatchState":true,"Index":0,"Angle":0,"X":100,"Y":200,"Width":32,"Height":32},{"MatchVal":0.88,"MatchState":true,"Index":1,"Angle":0,"X":150,"Y":220,"Width":32,"Height":32},{"MatchVal":0.80,"MatchState":true,"Index":2,"Angle":0,"X":300,"Y":100,"Width":32,"Height":32}]', 2, 120, 210)完整示例
以下示例演示:识别接口获取结果 → 转换为 JSON → 查找最近点 → 解析单个结果。
颜色识别:找离鼠标最近的色点
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t targetX = 500, targetY = 300;
auto colorPoints = ola.FindColorListEx(0, 0, 0, 0, "[{\"StartColor\":\"FFFF00\",\"EndColor\":\"FFFF00\"}]");
if (colorPoints.empty()) return;
std::string colorJson = "[";
for (size_t i = 0; i < colorPoints.size(); ++i) {
if (i > 0) colorJson += ",";
colorJson += ola.toJSON(colorPoints[i]);
}
colorJson += "]";
// type=1,返回单个最近点 JSON
std::string nearestJson = ola.FindNearestPos(colorJson.c_str(), 1, targetX, targetY);
// 颜色识别返回 {"x":..,"y":..}(小写键名)
int64_t root = ola.JsonParse(nearestJson.c_str(), &err);
if (root != 0 && err == 0) {
int32_t getErr = 0;
int32_t x = (int32_t)ola.JsonGetNumber(root, "x", &getErr);
int32_t y = (int32_t)ola.JsonGetNumber(root, "y", &getErr);
ola.JsonFree(root);
}csharp
using OLAPlug;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Linq;
var ola = new OLAPlugServer();
int targetX = 500, targetY = 300;
var colorPoints = ola.FindColorListEx(0, 0, 0, 0, @"[{""StartColor"":""FFFF00"",""EndColor"":""FFFF00""}]");
if (colorPoints.Count == 0) return;
string colorJson = "[" + string.Join(",", colorPoints.Select(p => p.ToJSON())) + "]";
string nearestJson = ola.FindNearestPos(colorJson, 1, targetX, targetY);
// 颜色识别返回 {"x":..,"y":..}
var nearest = JObject.Parse(nearestJson);
int x = nearest["x"].Value<int>();
int y = nearest["y"].Value<int>();python
import json
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
target_x, target_y = 500, 300
color_points = ola.FindColorListEx(0, 0, 0, 0, '[{"StartColor":"FFFF00","EndColor":"FFFF00"}]')
if not color_points:
return
color_json = json.dumps(color_points, ensure_ascii=False)
nearest_json = ola.FindNearestPos(color_json, 1, target_x, target_y)
# 颜色识别返回 {"x":..,"y":..}
nearest = json.loads(nearest_json)
x = nearest["x"]
y = nearest["y"]java
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.olaplug.OLAPlugServer;
import com.olaplug.model.Point;
import java.util.List;
OLAPlugServer ola = new OLAPlugServer();
ObjectMapper mapper = new ObjectMapper();
int targetX = 500, targetY = 300;
List<Point> colorPoints = ola.FindColorListEx(0, 0, 0, 0, "[{\"StartColor\":\"FFFF00\",\"EndColor\":\"FFFF00\"}]");
if (colorPoints == null || colorPoints.isEmpty()) return;
String colorJson = colorPoints.stream()
.map(Point::toJSON)
.collect(java.util.stream.Collectors.joining(",", "[", "]"));
String nearestJson = ola.FindNearestPos(colorJson, 1, targetX, targetY);
// 颜色识别返回 {"x":..,"y":..}
JsonNode nearest = mapper.readTree(nearestJson);
int x = nearest.get("x").asInt();
int y = nearest.get("y").asInt();go
import (
"encoding/json"
"github.com/ola/olaplug/olaplug"
)
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
targetX, targetY := int32(500), int32(300)
colorPoints := ola.FindColorListEx(0, 0, 0, 0, `[{"StartColor":"FFFF00","EndColor":"FFFF00"}]`)
if len(colorPoints) == 0 {
return
}
colorJson, _ := json.Marshal(colorPoints)
nearestJson := ola.FindNearestPos(string(colorJson), 1, targetX, targetY)
var nearest map[string]int32
if json.Unmarshal([]byte(nearestJson), &nearest) == nil {
x := nearest["x"]
y := nearest["y"]
_ = x
_ = y
}rust
use olaplug::OLAPlugServer;
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let target_x = 500;
let target_y = 300;
let color_points = ola.find_color_list_ex(0, 0, 0, 0, r#"[{"StartColor":"FFFF00","EndColor":"FFFF00"}]"#);
if color_points.is_empty() {
return;
}
let color_json = format!(
"[{}]",
color_points.iter().map(|p| p.toJSON()).collect::<Vec<_>>().join(",")
);
let nearest_json = ola.find_nearest_pos(&color_json, 1, target_x, target_y);
if let Ok(nearest) = serde_json::from_str::<serde_json::Value>(&nearest_json) {
let x = nearest["x"].as_i64().unwrap_or(0);
let y = nearest["y"].as_i64().unwrap_or(0);
let _ = (x, y);
}图像识别:找离屏幕中心最近的匹配
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t targetX = 960, targetY = 540;
long imgPtr = ola.LoadImage("scene.png");
long templPtr = ola.LoadImage("button.bmp");
auto matchResults = ola.FindImageFromPtrAll(imgPtr, templPtr, "101010", 0.9);
if (!matchResults.empty()) {
std::string matchJson = "[";
for (size_t i = 0; i < matchResults.size(); ++i) {
if (i > 0) matchJson += ",";
matchJson += ola.toJSON(matchResults[i]);
}
matchJson += "]";
std::string nearestJson = ola.FindNearestPos(matchJson.c_str(), 2, targetX, targetY);
// 图像识别返回单个 MatchResult 对象
int32_t matchState = 0, x = 0, y = 0, width = 0, height = 0, index = 0;
double matchVal = 0, angle = 0;
ola.ParseMatchImageJson(nearestJson.c_str(), &matchState, &x, &y, &width, &height, &matchVal, &angle, &index);
}
ola.FreeImage(imgPtr);
ola.FreeImage(templPtr);csharp
using OLAPlug;
using Newtonsoft.Json;
using System.Linq;
var ola = new OLAPlugServer();
int targetX = 960, targetY = 540;
long imgPtr = ola.LoadImage("scene.png");
long templPtr = ola.LoadImage("button.bmp");
var matchResults = ola.FindImageFromPtrAll(imgPtr, templPtr, "101010", 0.9);
if (matchResults.Count > 0)
{
string matchJson = "[" + string.Join(",", matchResults.Select(m => m.ToJSON())) + "]";
string nearestJson = ola.FindNearestPos(matchJson, 2, targetX, targetY);
// 图像识别返回单个 MatchResult
var nearest = JsonConvert.DeserializeObject<MatchResult>(nearestJson);
if (nearest != null && nearest.MatchState)
{
int x = nearest.X;
int y = nearest.Y;
}
}
ola.FreeImage(imgPtr);
ola.FreeImage(templPtr);python
import json
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
target_x, target_y = 960, 540
img_ptr = ola.LoadImage("scene.png")
templ_ptr = ola.LoadImage("button.bmp")
match_results = ola.FindImageFromPtrAll(img_ptr, templ_ptr, "101010", 0.9)
if match_results:
match_json = json.dumps(match_results, ensure_ascii=False)
nearest_json = ola.FindNearestPos(match_json, 2, target_x, target_y)
# 图像识别返回单个 MatchResult 字典
nearest = json.loads(nearest_json)
if nearest.get("MatchState"):
x = nearest["X"]
y = nearest["Y"]
ola.FreeImage(img_ptr)
ola.FreeImage(templ_ptr)java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.olaplug.OLAPlugServer;
import com.olaplug.model.MatchResult;
import java.util.List;
OLAPlugServer ola = new OLAPlugServer();
ObjectMapper mapper = new ObjectMapper();
int targetX = 960, targetY = 540;
long imgPtr = ola.LoadImage("scene.png");
long templPtr = ola.LoadImage("button.bmp");
List<MatchResult> matchResults = ola.FindImageFromPtrAll(imgPtr, templPtr, "101010", 0.9);
if (matchResults != null && !matchResults.isEmpty()) {
String matchJson = matchResults.stream()
.map(MatchResult::toJSON)
.collect(java.util.stream.Collectors.joining(",", "[", "]"));
String nearestJson = ola.FindNearestPos(matchJson, 2, targetX, targetY);
MatchResult nearest = mapper.readValue(nearestJson, MatchResult.class);
if (nearest.MatchState) {
int x = nearest.X;
int y = nearest.Y;
}
}
ola.FreeImage(imgPtr);
ola.FreeImage(templPtr);go
import (
"encoding/json"
"github.com/ola/olaplug/olaplug"
)
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
targetX, targetY := int32(960), int32(540)
imgPtr := ola.LoadImage("scene.png")
templPtr := ola.LoadImage("button.bmp")
matchResults := ola.FindImageFromPtrAll(imgPtr, templPtr, "101010", 0.9)
if len(matchResults) > 0 {
matchJson, _ := json.Marshal(matchResults)
nearestJson := ola.FindNearestPos(string(matchJson), 2, targetX, targetY)
var nearest olaplug.MatchData
if json.Unmarshal([]byte(nearestJson), &nearest) == nil && nearest.MatchState {
x := nearest.X
y := nearest.Y
_ = x
_ = y
}
}
ola.FreeImage(imgPtr)
ola.FreeImage(templPtr)rust
use olaplug::{MatchData, OLAPlugServer};
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let target_x = 960;
let target_y = 540;
let img_ptr = ola.load_image("scene.png");
let templ_ptr = ola.load_image("button.bmp");
let match_results = ola.find_image_from_ptr_all(img_ptr, templ_ptr, "101010", 0.9);
if !match_results.is_empty() {
let match_json = format!(
"[{}]",
match_results.iter().map(|m| m.toJSON()).collect::<Vec<_>>().join(",")
);
let nearest_json = ola.find_nearest_pos(&match_json, 2, target_x, target_y);
if let Ok(nearest) = serde_json::from_str::<MatchData>(&nearest_json) {
if nearest.match_state {
let _ = (nearest.x, nearest.y);
}
}
}
ola.free_image_ptr(img_ptr);
ola.free_image_ptr(templ_ptr);原生 DLL
cpp
long instance = CreateCOLAPlugInterFace();
long colorPtr = FindColorListEx(instance, 0, 0, 0, 0, "[{\"StartColor\":\"FFFF00\",\"EndColor\":\"FFFF00\"}]");
if (colorPtr != 0) {
char colorJson[65536] = {0};
GetStringFromPtr(colorPtr, colorJson, sizeof(colorJson));
FreeStringPtr(colorPtr);
long nearestPtr = FindNearestPos(instance, colorJson, 1, 500, 300);
if (nearestPtr != 0) {
char nearestJson[256] = {0};
GetStringFromPtr(nearestPtr, nearestJson, sizeof(nearestJson));
FreeStringPtr(nearestPtr);
int err = 0;
long root = JsonParse(instance, nearestJson, &err);
if (root != 0 && err == 0) {
int x = (int)JsonGetNumber(instance, root, "x", &err);
int y = (int)JsonGetNumber(instance, root, "y", &err);
JsonFree(instance, root);
}
}
}csharp
long colorPtr = FindColorListEx(instance, 0, 0, 0, 0, "[{\"StartColor\":\"FFFF00\",\"EndColor\":\"FFFF00\"}]");
if (colorPtr != 0) {
var sb = new StringBuilder(GetStringSize(colorPtr) + 1);
GetStringFromPtr(colorPtr, sb, sb.Capacity);
FreeStringPtr(colorPtr);
long nearestPtr = FindNearestPos(instance, sb.ToString(), 1, 500, 300);
// 读取 nearestPtr,颜色结果键名为小写 x/y
}python
color_ptr = ola.FindColorListEx(instance, 0, 0, 0, 0, b'[{"StartColor":"FFFF00","EndColor":"FFFF00"}]')
if color_ptr:
buf = create_string_buffer(65536)
ola.GetStringFromPtr(color_ptr, buf, 65536)
ola.FreeStringPtr(color_ptr)
nearest_ptr = ola.FindNearestPos(instance, buf.value, 1, 500, 300)
# json.loads 后取 nearest["x"], nearest["y"]返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 返回离目标点最近的单个结果 JSON 字符串。SDK 封装已自动拷贝字符串;原生 DLL 返回的字符串指针需调用 FreeStringPtr 释放内存。 |
type = 1(颜色识别) 返回:
json
{"x": 100, "y": 200}| 字段名 | 类型 | 说明 |
|---|---|---|
| x | 整数 | 最近点的 X 坐标(小写键名)。 |
| y | 整数 | 最近点的 Y 坐标(小写键名)。 |
type = 2(图像识别) 返回单个 MatchResult 对象:
json
{
"MatchVal": 0.85,
"MatchState": true,
"Index": 0,
"Angle": 0,
"X": 100,
"Y": 200,
"Width": 32,
"Height": 32
}| 字段名 | 类型 | 说明 |
|---|---|---|
| MatchVal | 浮点数 | 匹配相似度。 |
| MatchState | 布尔 | 是否匹配成功。 |
| Index | 整数 | 结果索引(从 0 开始)。 |
| Angle | 浮点数 | 匹配角度。 |
| X | 整数 | X 坐标。 |
| Y | 整数 | Y 坐标。 |
| Width | 整数 | 宽度。 |
| Height | 整数 | 高度。 |
图像结果可用 ParseMatchImageJson 解析;颜色结果可用 JsonParse 读取 x/y 字段。
