匹配动画窗口 - MatchAnimationFromPath
函数简介
匹配动画窗口,可用于GIF动画识别。可在识别指定时间内动图。查找到立马返回结果,返回相对绑定窗口坐标坐标
识别结果最长等待时间为time+1000ms
x1 , y1, x2, y2传 0, 0, 0, 0 为窗口整个客户区
返回数据类型解析:
{
"MatchVal": 0.85,//数据相似度
"MatchState": true,//返回数据是否大于指定精度,用于快速判断识别结果
"Index": 0,//多图识别时的返回索引
"Angle": 45.0,//识别结果角度
"MatchPoint": {
"x": 100,//识别结果X坐标
"y": 200//识别结果Y坐标
}
}
接口名称
MatchAnimationFromPath
DLL调用
long MatchAnimationFromPath(long ola, int x1, int y1, int x2, int y2, string templ, double matchVal, int type, double angle, double scale,int delay, int time, int threadCount)
参数定义:
ola
(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。x1
(整型数): 查找区域的左上角X坐标。y1
(整型数): 查找区域的左上角Y坐标。x2
(整型数): 查找区域的右下角X坐标。y2
(整型数): 查找区域的右下角Y坐标。templ
(字符串): 模板图片的路径,可以是多个图片,比如"test.bmp|test2.bmp|test3.bmp"。matchVal
(双精度浮点数): 相似度,如0.85,最大为1。type
(整型数): 匹配类型:- 1:灰度匹配,速度快;
- 2:彩色匹配;
- 3:透明匹配。
angle
(双精度浮点数): 旋转角度,每次匹配后旋转指定角度继续进行匹配,直到匹配成功,角度越小匹配次数越多时间越长。0为不旋转速度最快。scale
(双精度浮点数): 窗口缩放比例,默认为1 可以通过GetScaleFromWindows接口读取当前窗口缩放。delay
(整型数): 动画间隔,单位毫秒。time
(整型数): 总共识别多久的动画,单位毫秒。threadCount
(整型数): 用于查找的线程数线程数根据delay帧率自行调整,过小会导致识别时间到期未识别完,过大会导致CPU占用过大。
示例:
待补充...
COM调用
string MatchAnimationFromPath(int x1, int y1, int x2, int y2, string templ, double matchVal, int type, double angle, double scale,int delay, int time, int threadCount)
参数定义:
x1 整型数 : 查找区域的左上角X坐标
y1 整型数 : 查找区域的左上角Y坐标
x2 整型数 : 查找区域的右下角X坐标
y2 整型数 : 查找区域的右下角Y坐标
templ 字符串 : 模板图片的路径,可以是多个图片,比如"test.bmp|test2.bmp|test3.bmp"
matchVal 双精度浮点数 : 相似度,如0.85,最大为1
type 整型数 :
1:灰度匹配,速度快;
2:彩色匹配;
3:透明匹配;
angle 双精度浮点数 : 旋转角度,每次匹配后旋转指定角度继续进行匹配,直到匹配成功,角度越小匹配次数越多时间越长。0为不旋转速度最快
scale 双精度浮点数 :窗口缩放比例,默认为1 可以通过GetScaleFromWindows接口读取当前窗口缩放
delay 整型数 : 动画间隔,单位毫秒。
time 整型数 : 总共识别多久的动画,单位毫秒。
threadCount 整型数 : 用于查找的线程数线程数根据delay帧率自行调整,过小会导致识别时间到期未识别完,过大会导致CPU占用过大
示例:
ret = MatchAnimationFromPath(0,0,0,0,"OLA/pic/pic.bmp", 0.85, 1, 50.0, 1.0,20,1000,5)
messagebox(ret) #ret为json字符串
返回值
字符串:
返回匹配结果,如
{
"MatchVal": 0.85,
"MatchState": true,
"Index": 0,
"Angle": 45.0,
"MatchPoint": {
"x": 100,
"y": 200
}
}
注意:
DLL调用返回字符串指针地址,需要调用 FreeStringPtr接口释放内存