主题
获取匹配图像JSON数量 - GetMatchImageAllCount
函数简介
获取匹配图像JSON数组中的匹配结果数量。
接口名称
GetMatchImageAllCountDLL调用
c
int GetMatchImageAllCount(string str);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| str | 字符串 | 匹配图像JSON字符串。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// MatchImageFromPathAll 等返回的多结果 JSON 数组
const char* resultJson = "[{\"MatchState\":true,\"X\":120,\"Y\":80,\"Width\":32,\"Height\":32,\"MatchVal\":0.95,\"Angle\":0,\"Index\":0},{\"MatchState\":true,\"X\":300,\"Y\":200,\"Width\":32,\"Height\":32,\"MatchVal\":0.88,\"Angle\":0,\"Index\":1}]";
int32_t count = ola.GetMatchImageAllCount(resultJson); // 此处为 2csharp
using OLAPlug;
var ola = new OLAPlugServer();
// MatchImageFromPathAll 等返回的多结果 JSON 数组
string resultJson = "[{\"MatchState\":true,\"X\":120,\"Y\":80,\"Width\":32,\"Height\":32,\"MatchVal\":0.95,\"Angle\":0,\"Index\":0},{\"MatchState\":true,\"X\":300,\"Y\":200,\"Width\":32,\"Height\":32,\"MatchVal\":0.88,\"Angle\":0,\"Index\":1}]";
int count = ola.GetMatchImageAllCount(resultJson); // 此处为 2python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
# MatchImageFromPathAll 等返回的多结果 JSON 数组
result_json = '[{"MatchState":true,"X":120,"Y":80,"Width":32,"Height":32,"MatchVal":0.95,"Angle":0,"Index":0},{"MatchState":true,"X":300,"Y":200,"Width":32,"Height":32,"MatchVal":0.88,"Angle":0,"Index":1}]'
count = ola.GetMatchImageAllCount(result_json) # 此处为 2java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
String resultJson = "[{\"MatchState\":true,\"X\":120,\"Y\":80,\"Width\":32,\"Height\":32,\"MatchVal\":0.95,\"Angle\":0,\"Index\":0},{\"MatchState\":true,\"X\":300,\"Y\":200,\"Width\":32,\"Height\":32,\"MatchVal\":0.88,\"Angle\":0,\"Index\":1}]";
int count = ola.GetMatchImageAllCount(resultJson);cpp
var ola = com("OlaPlug.OlaSoft")
var resultJson = "[{\"MatchState\":true,\"X\":120,\"Y\":80,\"Width\":32,\"Height\":32,\"MatchVal\":0.95,\"Angle\":0,\"Index\":0},{\"MatchState\":true,\"X\":300,\"Y\":200,\"Width\":32,\"Height\":32,\"MatchVal\":0.88,\"Angle\":0,\"Index\":1}]"
var count = ola.GetMatchImageAllCount(resultJson)vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
resultJson = "[{\""MatchState\"":true,\""X\"":120,\""Y\"":80,\""Width\"":32,\""Height\"":32,\""MatchVal\"":0.95,\""Angle\"":0,\""Index\"":0},{\""MatchState\"":true,\""X\"":300,\""Y\"":200,\""Width\"":32,\""Height\"":32,\""MatchVal\"":0.88,\""Angle\"":0,\""Index\"":1}]"
count = ola.GetMatchImageAllCount(resultJson)text
.局部变量 ola, OLAPlug
ola.创建 ()
resultJson = “[{“MatchState“:true,“X“:120,“Y“:80,“Width“:32,“Height“:32,“MatchVal“:0.95,“Angle“:0,“Index“:0},{“MatchState“:true,“X“:300,“Y“:200,“Width“:32,“Height“:32,“MatchVal“:0.88,“Angle“:0,“Index“:1}]“
count = ola.GetMatchImageAllCount (resultJson)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var resultJson = "[{\"MatchState\":true,\"X\":120,\"Y\":80,\"Width\":32,\"Height\":32,\"MatchVal\":0.95,\"Angle\":0,\"Index\":0},{\"MatchState\":true,\"X\":300,\"Y\":200,\"Width\":32,\"Height\":32,\"MatchVal\":0.88,\"Angle\":0,\"Index\":1}]";
var count = ola.GetMatchImageAllCount(resultJson);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
文本型 resultJson = "[{\"MatchState\":true,\"X\":120,\"Y\":80,\"Width\":32,\"Height\":32,\"MatchVal\":0.95,\"Angle\":0,\"Index\":0},{\"MatchState\":true,\"X\":300,\"Y\":200,\"Width\":32,\"Height\":32,\"MatchVal\":0.88,\"Angle\":0,\"Index\":1}]"
整数 count = ola.GetMatchImageAllCount(resultJson)cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
const char* resultJson = "[{\"MatchState\":true,\"X\":120,\"Y\":80,\"Width\":32,\"Height\":32,\"MatchVal\":0.95,\"Angle\":0,\"Index\":0},{\"MatchState\":true,\"X\":300,\"Y\":200,\"Width\":32,\"Height\":32,\"MatchVal\":0.88,\"Angle\":0,\"Index\":1}]";
int32_t count = ola.GetMatchImageAllCount(resultJson);原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
const char* resultJson = "[{\"MatchState\":true,\"X\":120,\"Y\":80,\"Width\":32,\"Height\":32,\"MatchVal\":0.95,\"Angle\":0,\"Index\":0},{\"MatchState\":true,\"X\":300,\"Y\":200,\"Width\":32,\"Height\":32,\"MatchVal\":0.88,\"Angle\":0,\"Index\":1}]";
int count = GetMatchImageAllCount(instance, resultJson);csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetMatchImageAllCount(long ola, string str);
long instance = CreateCOLAPlugInterFace();
string resultJson = "[{\"MatchState\":true,\"X\":120,\"Y\":80,\"Width\":32,\"Height\":32,\"MatchVal\":0.95,\"Angle\":0,\"Index\":0},{\"MatchState\":true,\"X\":300,\"Y\":200,\"Width\":32,\"Height\":32,\"MatchVal\":0.88,\"Angle\":0,\"Index\":1}]";
int count = GetMatchImageAllCount(instance, resultJson);python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
result_json = b'[{"MatchState":true,"X":120,"Y":80,"Width":32,"Height":32,"MatchVal":0.95,"Angle":0,"Index":0},{"MatchState":true,"X":300,"Y":200,"Width":32,"Height":32,"MatchVal":0.88,"Angle":0,"Index":1}]'
count = ola.GetMatchImageAllCount(instance, result_json)返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 返回匹配图像JSON数量,解析失败时返回0。 |
注意事项
| 项目 | 说明 |
|---|---|
| 用于获取匹配图像返回的JSON数组长度 | 用于获取匹配图像返回的JSON数组长度。 |
| 格式 | JSON格式应为数组格式,包含一个或多个匹配结果对象。 |
| 返回的数量可用于后续遍历所有匹配结果 | 返回的数量可用于后续遍历所有匹配结果。 |
