获取前景点 - GetForegroundPoints
函数简介
获取二值化图像中的前景点坐标信息,以JSON格式返回。
接口名称
GetForegroundPoints
DLL调用
long GetForegroundPoints(long instance, long ptr);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| ptr | 长整数型 | 图像指针 |
示例
long image = LoadImage(ola, "D:\\test\\image.png");
if (image != 0) {
long pointsPtr = GetForegroundPoints(ola, image);
if (pointsPtr != 0) {
printf("前景点JSON: %s\n", (char*)pointsPtr);
FreeStringPtr(ola, pointsPtr);
}
FreeImagePtr(ola, image);
}
返回值
长整数型:返回前景点数组的JSON字符串指针,格式为 [{"x":10,"y":10},{"x":20,"y":20}]。失败返回0。
注意事项
- 返回的字符串指针需调用 FreeStringPtr 释放内存。
- 前景点检测基于图像的非零像素。
- 建议与 Threshold 函数配合使用。
