在 robot framework 上封装 nodecv-server 的视觉判断关键字
关键字封装opencv连接接口服务
根据API配置中接口服务器地址:${opencv_server_url}连接接口服务
create session opencv ${opencv_server_url}
opencv关闭接口服务连接
关闭所有服务
delete all sessions
opencv_dissimilarity
${image1} ${image2}
差异度 dissimilarity 的值 越小 差异 越小
... ${image1} ./image/macaca.png图片名称只能使用字母数字及下划线
... ${image2} ./image/macaca_logo.png
${image1} _图片信息拼装 ${image1}
${image2} _图片信息拼装 ${image2}
${files} create dictionary image1=${image1} image2=${image2}
${addr} post request opencv ${POST_diss} files=${files}
should be equal as strings ${addr.status_code} 200
${responsedata} to json ${addr.content}
log ${responsedata}
${responsedata}
opencv_matchtemplate
${image1} ${image2}
... ${image1} ./image/macaca.png 被匹配标记的大图
... ${image2} ./image/macaca_logo.png 为需要匹配的小图,
... 最好是颜色较深的 图片 带文字效果不好,获取小图在大图中的位置(坐标信息)
${image1} _图片信息拼装 ${image1}
${image2} _图片信息拼装 ${image2}
${files} create dictionary image1=${image1} image2=${image2}
${addr} post request opencv ${POST_match} files=${files}
should be equal as strings ${addr.status_code} 200
${responsedata} to json ${addr.content}
log ${responsedata}
${responsedata}
opencv_cascadedetect
${image1} ${image2}
... ${image1} ./image/macaca.png
... ${image2} ./image/macaca_logo.png
${image1} _图片信息拼装 ${image1}
${image2} _图片信息拼装 ${image2}
# ${image1} evaluate ('image1', open('${image1}', 'rb'))
# ${image2} evaluate ('image2', open('${image2}', 'rb'))
${files} create dictionary image1=${image1} image2=${image2}
${addr} post request opencv ${POST_casca} files=${files}
should be equal as strings ${addr.status_code} 200
${responsedata} to json ${addr.content}
log ${responsedata}
${responsedata}
opencv_findpairs
${image1} ${image2}
... ${image1} ./image/macaca.png 图片名称只能使用字母数字及下划线
... ${image2} ./image/macaca_logo.png
${image1} _图片信息拼装 ${image1}
${image2} _图片信息拼装 ${image2}
${files} create dictionary image1=${image1} image2=${image2}
${addr} post request opencv ${POST_findpairs} files=${files}
should be equal as strings ${addr.status_code} 200
${responsedata} to json ${addr.content}
log ${responsedata}
${responsedata}
_图片信息拼装
${image}
# ${i_name} get image name ${image}
# ${i_type} get image type ${i_name}
${i_name} evaluate re.search('\\w+\\.\\w+','${image}').group() re
${i_type} evaluate re.search('\\.\\w+','${i_name}').group() re
${i_type} Set Variable ${i_type}
${image} evaluate ('${i_name}', open('${image}', 'rb'), 'image/${i_type}', {'Expires': '0'})
${image}关键字应用
8dol点击我的_微信登录
8dol_app_点击进入_登录引导页_微信登录
8dol_app_等待加载_微信登录页
sleep 1
${image} PK_8dol截屏 wechat_login
${responsedata} opencv_matchtemplate ${image} image/wechat_login.png
log ${responsedata}
${match} get from dictionary ${responsedata} match
${x_center} evaluate float(${match})+float(${match})/2
${y_center} evaluate float(${match})+float(${match})/2
PK_点击_坐标 ${x_center} ${y_center} #点击确认登录按钮
我看到了“最好是”、“效果不好” 乐哈哈yoyo 发表于 2017-6-28 15:42
我看到了“最好是”、“效果不好”
呵呵 在我们app上用 效果 确实不太好!
不过还是有些场景可以用
在调用微信登录时, 正好用上
页:
[1]