查找图片3 - FindImageFromPtrAll
函数简介
在指定图片中查找指定图像的所有匹配位置,源图与模板均通过内存指针传入,返回全部匹配结果。
接口名称
FindImageFromPtrAll
DLL调用
long FindImageFromPtrAll(long instance, long source, long templ, string deltaColor, double matchVal);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| source | 长整数型 | OLAImage对象的地址(源图片) |
| templ | 长整数型 | OLAImage对象的地址(模板图片),由LoadImage等接口生成 |
| deltaColor | 字符串 | 颜色差值,格式为"RRGGBB",如"101010" |
| matchVal | 双精度浮点数 | 相似度,如0.85,最大为1 |
示例
C++
long instance = CreateCOLAPlugInterFace();
long source = LoadImage(instance, "source.bmp");
long templ = LoadImage(instance, "templ.bmp");
// 通过内存指针查找所有匹配位置
long resultPtr = FindImageFromPtrAll(instance, source, templ, "101010", 0.85);
char* result = GetStringFromPtr(instance, resultPtr);
FreeStringPtr(instance, resultPtr);
Python
# 待补充
返回值
字符串指针,返回JSON数组格式的所有匹配结果。DLL调用返回字符串指针地址,需要调用 FreeStringPtr 接口释放内存。
返回数据格式:
[{
"MatchVal": 0.85,
"MatchState": true,
"Index": 0,
"X": 100,
"Y": 200,
"Width": 100,
"Height": 100
}]
| 字段名 | 类型 | 说明 |
|---|---|---|
| MatchVal | 浮点数 | 匹配相似度。 |
| MatchState | 布尔 | 是否匹配成功。 |
| Index | 整数 | 结果索引(从 0 开始)。 |
| X | 整数 | X 坐标。 |
| Y | 整数 | Y 坐标。 |
| Width | 整数 | 宽度。 |
| Height | 整数 | 高度。 |
