获取最近可行区域点 - FindNearestFeasiblePoint
函数简介
在给定图像中,查询指定坐标点最近的可行区域点坐标。
建议传入二值化图像:白色区域表示可通行,黑色区域表示障碍。
接口名称
FindNearestFeasiblePoint
DLL调用
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坐标。 |
示例
C++
long instance = CreateCOLAPlugInterFace();
long image = 0; // 二值化图像句柄
int nearestX = 0;
int nearestY = 0;
// 查询点(120, 300)最近的可行区域点
int ret = FindNearestFeasiblePoint(instance, image, 120, 300, &nearestX, &nearestY);
if (ret == 1) {
// nearestX, nearestY 即最近可行点
}
Python
# 待补充
返回值
1:成功。0:失败(坐标越界或不存在可行点)。
