Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
京
京东搜索采集自动验证
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄梓誉
京东搜索采集自动验证
Commits
4aab3742
Commit
4aab3742
authored
Feb 22, 2024
by
huangziyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
8a3c8b70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
4 deletions
+36
-4
京东搜索_自动版.py
京东搜索_自动版.py
+36
-4
No files found.
京东搜索_自动版.py
View file @
4aab3742
...
...
@@ -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}'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment