主题
坐标点排序 - SortPosDistance
函数简介
根据坐标点距离排序,用于颜色识别结果及图像识别结果的排序。
接口名称
SortPosDistanceDLL调用
c
long SortPosDistance(long ola, char* json, int type, int x, int y);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| json | 字符串 | 识别结果返回值。 |
| type | 整数型 | 识别类型:1 颜色识别,2 图像识别。 |
| x | 整数型 | 锚点的X坐标。 |
| y | 整数型 | 锚点的Y坐标。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
std::string sorted = ola.SortPosDistance("[{\"x\":100,\"y\":200,\"id\":1},{\"x\":150,\"y\":220,\"id\":2},{\"x\":300,\"y\":100,\"id\":3}]", 2, 120, 210);csharp
using OLAPlug;
var ola = new OLAPlugServer();
string sorted = ola.SortPosDistance(@"[{"x":100,"y":200,"id":1},{"x":150,"y":220,"id":2},{"x":300,"y":100,"id":3}]", 2, 120, 210);python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
sorted_list = ola.SortPosDistance(r'[{"x":100,"y":200,"id":1},{"x":150,"y":220,"id":2},{"x":300,"y":100,"id":3}]', 2, 120, 210)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
ola.SortPosDistance("[{\"x\":100,\"y\":200,\"id\":1},{\"x\":150,\"y\":220,\"id\":2},{\"x\":300,\"y\":100,\"id\":3}]", 2, 120, 210);cpp
var ola = com("OlaPlug.OlaSoft")
ola.SortPosDistance("[{\"x\":100,\"y\":200,\"id\":1},{\"x\":150,\"y\":220,\"id\":2},{\"x\":300,\"y\":100,\"id\":3}]", 2, 120, 210);vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.SortPosDistance("[{\"x\":100,\"y\":200,\"id\":1},{\"x\":150,\"y\":220,\"id\":2},{\"x\":300,\"y\":100,\"id\":3}]", 2, 120, 210);text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.SortPosDistance(“[{\“x\“:100,\“y\“:200,\“id\“:1},{\“x\“:150,\“y\“:220,\“id\“:2},{\“x\“:300,\“y\“:100,\“id\“:3}]“, 2, 120, 210);aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.SortPosDistance("[{\"x\":100,\"y\":200,\"id\":1},{\"x\":150,\"y\":220,\"id\":2},{\"x\":300,\"y\":100,\"id\":3}]", 2, 120, 210);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.SortPosDistance("[{\"x\":100,\"y\":200,\"id\":1},{\"x\":150,\"y\":220,\"id\":2},{\"x\":300,\"y\":100,\"id\":3}]", 2, 120, 210);cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
ola.SortPosDistance("[{\"x\":100,\"y\":200,\"id\":1},{\"x\":150,\"y\":220,\"id\":2},{\"x\":300,\"y\":100,\"id\":3}]", 2, 120, 210);原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
std::string sorted = SortPosDistance("[{\"x\":100,\"y\":200,\"id\":1},{\"x\":150,\"y\":220,\"id\":2},{\"x\":300,\"y\":100,\"id\":3}]", 2, 120, 210);csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
string sorted = SortPosDistance(@"[{"x":100,"y":200,"id":1},{"x":150,"y":220,"id":2},{"x":300,"y":100,"id":3}]", 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()
sorted_list = ola.SortPosDistance(r'[{"x":100,"y":200,"id":1},{"x":150,"y":220,"id":2},{"x":300,"y":100,"id":3}]', 2, 120, 210)返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 返回按距离排序后的坐标点列表字符串指针。 返回的字符串指针需要调用 FreeStringPtr 释放内存。 |
