查找文字 - FindStrFromPtr
函数简介
从指定图片中查找文字。
接口名称
FindStrFromPtr
DLL调用
long FindStrFromPtr(long instance, long source, string str, string colorJson, string dict, double matchVal);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| source | 长整数型 | 源图片对象的指针 |
| str | 字符串 | 查找字符串 |
| colorJson | 字符串 | 颜色模型配置字符串,用于限定识别区域的颜色范围,格式说明见 颜色模型说明 - ColorModel。JSON格式示例:[{"StartColor":"3278FA","EndColor":"6496FF","Type":0}];简化格式示例:`3278FA-000000 |
| dict | 字符串 | 字库名称,为空时搜索所有字库 |
| matchVal | 双精度浮点数 | 匹配值 |
示例
C++
long instance = CreateCOLAPlugInterFace();
long source = LoadImage(instance, "test.bmp");
// 从指定图片中查找文字"确定"
long resultPtr = FindStrFromPtr(instance, source, "确定", "FFFFFF-101010", "", 0.85);
char* json = GetStringFromPtr(instance, resultPtr);
FreeStringPtr(instance, resultPtr);
Python
# 待补充
返回值
字符串指针地址,返回JSON格式的匹配结果,如:
{
"MatchVal": 0.85,
"MatchState": true,
"Index": 0,
"Angle": 45.0,
"X": 100,
"Y": 200,
"Width": 100,
"Height": 100
}
| 字段名 | 类型 | 说明 |
|---|---|---|
| MatchVal | 浮点数 | 匹配相似度。 |
| MatchState | 布尔 | 是否匹配成功。 |
| Index | 整数 | 结果索引(从 0 开始)。 |
| Angle | 浮点数 | 匹配角度。 |
| X | 整数 | X 坐标。 |
| Y | 整数 | Y 坐标。 |
| Width | 整数 | 宽度。 |
| Height | 整数 | 高度。 |
- MatchVal:数据相似度
- MatchState:返回数据是否大于指定精度,用于快速判断识别结果
- Index:多图识别时的返回索引
- Angle:识别结果角度
- X/Y:识别结果坐标
- Width/Height:识别结果宽高
返回的字符串指针需调用 FreeStringPtr 释放内存。
