Skip to content

获取最近可行区域点 - FindNearestFeasiblePoint

函数简介

在给定图像中,查询指定坐标点最近的可行区域点坐标。

建议传入二值化图像:白色区域表示可通行,黑色区域表示障碍。

接口名称

FindNearestFeasiblePoint

DLL调用

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);
}
go
import "github.com/ola/olaplug/olaplug"

ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
image := ola.LoadImage("maps/path_map.png")
if image != 0 {
    var nearestX int32
    var nearestY int32
    ret := ola.FindNearestFeasiblePoint(image, 100, 200, nearestX, nearestY)
    ola.FreeImage(image)
}
rust
use olaplug::OLAPlugServer;

let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let image = ola.load_image("maps/path_map.png");
if image != 0 {
    let mut nearestX: i32 = 0;
    let mut nearestY: i32 = 0;
    let ret = ola.find_nearest_feasible_point(image, 100, 200, &nearestX, &nearestY);
    ola.free_image(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 If
text
.局部变量 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:失败(坐标越界或不存在可行点)。