易盾增强版滑块识别
计算思路如下:
-
滑动条拖动距离传入 restrict 算法处理得到 初次值 J
-
J * 率值0.309375 得到滑块偏移量。
-
滑块的旋转角度=滑块偏移量*attrs
-
所以滑块偏移量=滑块的旋转角度/attrs
-
通过滑块偏移量 求出 滑动条拖动距离
python
# 应用高斯模糊
warped_image1 = cv2.GaussianBlur(warped_image1, ksize, sigmaX)
warped_image2 = cv2.GaussianBlur(warped_image2, ksize, sigmaX)
warped_image1 = cv2.adaptiveThreshold(warped_image1, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 11, 2)
warped_image2 = cv2.adaptiveThreshold(warped_image2, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 11, 2)
result = cv2.matchTemplate(warped_image2, warped_image1, cv2.TM_CCORR_NORMED)
# 找到最佳匹配位置
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
# max_val 是匹配差异,差异越小,俩个相似度越多
similarity = max_val
# 打印相似度
# print(f"差异度: {similarity}")
if similarity < mindif:
mindif = similarity
minpianyi = x_offset
allpianyi[x_offset] = similarity