defget_keynumber_location(self):'''获取字母对应位置
:return:返回template在image中的的bound参数'''keynum= pic_path + "\keynum.png" #键盘图片
image =cv2.imread(keynum)
key= cur_path + "\keyboard\%s.png" % 1 #数字键图片
template =cv2.imread(key)
h,w= template.shape[:2] #字母图片尺寸
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED) #图片对比
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result) #对比结果最大值最小值以及位置
br = (max_loc[0] + w,max_loc[1] +h)#cv2.rectangle(image,max_loc,br,[0,255,0],2)#cv2.imshow("pipei",image)#cv2.waitKey(0)#cv2.destroyAllWindows()
returnmax_loc, brdefclick_position(self):'''确定点击位置
:param password: 口令密码
:return:返回点击位置position'''a,b= self.get_keynumber_location() #template在image中的的bound参数
x = a[0] +b[0]
y= a[1] + b[1]
position= (x / 2,y / 2)
self.driver.tap([position])#点击
return position