从字库中识别文字 - OcrFromDictPtr
函数简介
从字库中识别指定图片的文字,需提前加载数据库。支持多个字库同时识别,多个字库用 | 分割,如 dict1|dict2。
接口名称
OcrFromDictPtr
DLL调用
long OcrFromDictPtr(long instance, long ptr, string colorJson, string dict_name, double matchVal);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| ptr | 长整数型 | 图像指针 |
| colorJson | 字符串 | 颜色模型配置字符串,用于限定图像匹配中的颜色范围,格式说明见 颜色模型说明 - ColorModel。JSON格式示例:[{"StartColor":"3278FA","EndColor":"6496FF","Type":0}];简化格式示例:`3278FA-000000 |
| dict_name | 字符串 | 字库名称,为空时搜索所有字库,也可以传入字库文件如 dict.txt |
| matchVal | 双精度浮点数 | 匹配值 |
示例
C++
long instance = CreateCOLAPlugInterFace();
long imgPtr = LoadImage(instance, "test.bmp");
// 从字库"mydict"中识别指定图片文字
long resultPtr = OcrFromDictPtr(instance, imgPtr, "FFFFFF-101010", "mydict", 0.85);
char* text = GetStringFromPtr(instance, resultPtr);
FreeStringPtr(instance, resultPtr);
Python
# 待补充
返回值
字符串指针地址,返回识别到的文字。返回的字符串指针需调用 FreeStringPtr 释放内存。
