Commit 4aab3742 authored by huangziyu's avatar huangziyu

1

parent 8a3c8b70
......@@ -30,9 +30,9 @@ mysql_zdzs_proxy_host = '59.110.219.171'
mysql_zdzs_proxy_user = 'zgcindex'
mysql_zdzs_proxy_password = 'zgcprice2019'
mysql_zdzs_proxy_database = 'zdzs_proxy'
username = 'xxx'
username = '13311252087'
# 登陆密码
password = 'xxx'
password = 'zaijian666'
# mysql_zdzs_proxy_host = '59.110.219.171'
# mysql_zdzs_proxy_user = 'zgcindex'
......@@ -220,11 +220,43 @@ def find_best_match_angle(background_img_path, rotating_img_path):
# 将旋转后的验证码图片放置到背景图的指定位置
new_background.paste(rotated_captcha, insert_position, rotated_captcha)
# 将PIL图像转换为NumPy数组
numpy_image = np.array(new_background)
# 将RGB格式的图像转换为BGR格式,因为OpenCV默认使用BGR格式
bgr_image = cv2.cvtColor(numpy_image, cv2.COLOR_RGB2BGR)
# 保存合成后的图片
gray = cv2.cvtColor(bgr_image, cv2.COLOR_BGR2GRAY)
new_background.save(f"captcha_{abs(angle)}.png")
distortion_level = detect_circular_distortion(f"captcha_{abs(angle)}.png")
# 确定圆形区域的中心和半径
circle_center = (gray.shape[1] // 2, gray.shape[0] // 2)
# 创建一个遮罩,只包含圆形区域
mask = np.zeros_like(gray)
cv2.circle(mask, circle_center, 65, 255, thickness=-1)
# 应用遮罩到图像
masked_img = cv2.bitwise_and(gray, gray, mask=mask)
# 初始化ORB检测器
orb = cv2.ORB_create(500)
# 检测并计算圆形区域和整个图像的关键点和描述符
kp1, des1 = orb.detectAndCompute(gray, None)
kp2, des2 = orb.detectAndCompute(masked_img, None)
# 匹配描述符
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1, des2)
# 计算匹配点的平均距离,作为扭曲程度的一个简单估计
if matches:
distances = [match.distance for match in matches]
average_distance = sum(distances) / len(distances)
else:
average_distance = float('inf')
# new_background.save(f"captcha_{abs(angle)}.png")
distortion_level = average_distance
if angle == -360:
best_score = distortion_level
print(f'中心区域扭曲程度估计(数值越小表示越接近未扭曲): {distortion_level}')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment