主题
快速识别数字 - FastNumberOcr
函数简介
快速识别指定窗口区域内的数字,使用预定义的数字图片模板进行匹配识别。
接口名称
FastNumberOcrDLL调用
int FastNumberOcr(long instance, int x1, int y1, int x2, int y2, string numbers, string colorJson, double matchVal);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| x1 | 整数型 | 区域左上角X坐标。 |
| y1 | 整数型 | 区域左上角Y坐标。 |
| x2 | 整数型 | 区域右下角X坐标。 |
| y2 | 整数型 | 区域右下角Y坐标。 |
| numbers | 字符串 | 0~9数字图片地址,多个数字用 `。 |
| colorJson | 字符串 | 颜色模型配置字符串,用于限定图像匹配中的颜色范围,格式说明见 颜色模型说明 - ColorModel。JSON格式示例:[{"StartColor":"3278FA","EndColor":"6496FF","Type":0}];简化格式示例:`3278FA-000000。 |
| matchVal | 双精度浮点数 | 识别率阈值,范围 0.0-1.0。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.FastNumberOcr(0, 0, 0, 0, "value", "value", 0.9);csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.FastNumberOcr(0, 0, 0, 0, "value", "value", 0.9);python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.FastNumberOcr(0, 0, 0, 0, "value", "value", 0.9)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
int ret = ola.FastNumberOcr(0, 0, 0, 0, "value", "value", 0.9);cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.FastNumberOcr(0, 0, 0, 0, "value", "value", 0.9)vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.FastNumberOcr(0, 0, 0, 0, "value", "value", 0.9)text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.FastNumberOcr(0, 0, 0, 0, “value”, “value”, 0.9)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.FastNumberOcr(0, 0, 0, 0, "value", "value", 0.9);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.FastNumberOcr(0, 0, 0, 0, "value", "value", 0.9)cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t ret = ola.FastNumberOcr(0, 0, 0, 0, "value", "value", 0.9);原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
FastNumberOcr(instance, 0, 0, 0, 0, "value", "value", 0.9);csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FastNumberOcr(long ola, int x1, int y1, int x2, int y2, string numbers, string colorJson, int matchVal);
long instance = CreateCOLAPlugInterFace();
FastNumberOcr(instance, 0, 0, 0, 0, "value", "value", 0.9);python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.FastNumberOcr(instance, 0, 0, 0, 0, "value", "value", 0.9)返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 整数型,返回识别到的数字,识别失败返回 -1。 |
注意事项
| 项目 | 说明 |
|---|---|
| 需要预先准备0-9数字的二值化图片模板 | 需要预先准备0-9数字的二值化图片模板。 |
| 路径 | 数字图片路径用 ` |
| matchVal 参数控制识别精度 | matchVal 参数控制识别精度,值越高要求匹配度越精确。 |
| 窗口绑定 | 使用前需要先绑定窗口。 |
| 坐标范围为窗口客户区坐标 | 坐标范围为窗口客户区坐标。 |
