主题
获取最近可行区域点 - FindNearestFeasiblePoint
函数简介
在给定图像中,查询指定坐标点最近的可行区域点坐标。
建议传入二值化图像:白色区域表示可通行,黑色区域表示障碍。
接口名称
FindNearestFeasiblePointDLL调用
c
int FindNearestFeasiblePoint(long instance, long image, int x, int y, int* nearestX, int* nearestY);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| image | 长整数型 | 图像句柄(建议为二值化图像,白色区域可通行,黑色区域障碍)。 |
| x | 整数型 | 待查询点X坐标。 |
| y | 整数型 | 待查询点Y坐标。 |
| nearestX | 整数型指针 | 返回最近可行点X坐标。 |
| nearestY | 整数型指针 | 返回最近可行点Y坐标。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long image = ola.LoadImage("maps/path_map.png");
if (image != 0) {
int nearestX, nearestY;
int ret = ola.FindNearestFeasiblePoint(image, 100, 200, nearestX, nearestY);
ola.FreeImage(image);
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
long image = ola.LoadImage("maps/path_map.png");
if (image != 0)
{
int ret = ola.FindNearestFeasiblePoint(image, 100, 200, out int nearestX, out int nearestY);
ola.FreeImage(image);
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
image = ola.LoadImage("maps/path_map.png")
if image != 0:
ret, nearest_x, nearest_y = ola.FindNearestFeasiblePoint(image, 100, 200)
ola.FreeImage(image)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long image = ola.LoadImage("maps/path_map.png");
if (image != 0) {
ola.FindNearestFeasiblePoint(image, 100, 200, 0, 0);
ola.FreeImage(image);
}cpp
var ola = com("OlaPlug.OlaSoft")
var image = ola.LoadImage("maps/path_map.png")
if(image) {
ola.FindNearestFeasiblePoint(image, 100, 200, 0, 0);
ola.FreeImage(image)
}vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
image = ola.LoadImage("maps/path_map.png")
If image <> 0 Then
ola.FindNearestFeasiblePoint(image, 100, 200, 0, 0);
ola.FreeImage(image)
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
image = ola.LoadImage ("maps/path_map.png")
.如果真 (image ≠ 0)
ola.FindNearestFeasiblePoint(image, 100, 200, 0, 0);
ola.FreeImage (image)
.如果真结束aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var image = ola.LoadImage("maps/path_map.png");
if(image){
ola.FindNearestFeasiblePoint(image, 100, 200, 0, 0);
ola.FreeImage(image);
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 image = ola.LoadImage("maps/path_map.png")
如果真 (image ≠ 0)
{
ola.FindNearestFeasiblePoint(image, 100, 200, 0, 0);
ola.FreeImage(image)
}cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long image = ola.LoadImage("maps/path_map.png");
if (image != 0) {
ola.FindNearestFeasiblePoint(image, 100, 200, 0, 0);
ola.FreeImage(image);
}原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long image = LoadImage(instance, "maps/path_map.png");
if (image != 0) {
int nearestX, nearestY;
int ret = ola.FindNearestFeasiblePoint(image, 100, 200, nearestX, nearestY);
FreeImage(instance, image);
}csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
long image = LoadImage(instance, "maps/path_map.png");
if (image != 0) {
int ret = ola.FindNearestFeasiblePoint(image, 100, 200, out int nearestX, out int nearestY);
FreeImage(instance, image);
}python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
image = ola.LoadImage(instance, b"maps/path_map.png")
if image:
ret, nearest_x, nearest_y = ola.FindNearestFeasiblePoint(image, 100, 200)
ola.FreeImage(instance, image)返回值
| 返回值 | 说明 |
|---|---|
1 | :成功。 |
0 | :失败(坐标越界或不存在可行点)。 |
