欢迎光临
我们一直在努力

百度旋转验证码识别

 一、简介

百度的旋转验证码现在基本上都是由AI生成的,每一张图片都不会重复,也会加入很多干扰因素,所以机器识别也越来越困难。

如下图就是百度AI旋转的识别与实际滑动效果,识别正确率几乎达到100%正确率。本身更新主要是解决了新增的一些AI图片的识别,后续我们也会持续更新,做到更好。

二、识别代码

识别这个AI旋转验证码只需要原图一张,或者是切边截图。当然原图的识别效果是最好的。截图正确率会相对低一些。

1、原图识别

原图是通过图片链接下载的图片,如下图所示

2、截图识别

截图的话需要按照下图红框截图,需要与圆形图片切边截图

错误的截图方式

3、识别代码

运行下面代码可以得到识别的角度,和旋转后的图片效果。

import base64
import requests
import datetime
from io import BytesIO
from PIL import Image

t1 = datetime.datetime.now()

#PIL图片保存为base64编码
def PIL_base64(img, coding='utf-8'):
img_format = img.format
if img_format == None:
img_format = 'JPEG'

format_str = 'JPEG'
if 'png' == img_format.lower():
format_str = 'PNG'
if 'gif' == img_format.lower():
format_str = 'gif'

if img.mode == "P":
img = img.convert('RGB')
if img.mode == "RGBA":
format_str = 'PNG'
img_format = 'PNG'

output_buffer = BytesIO()
# img.save(output_buffer, format=format_str)
img.save(output_buffer, quality=100, format=format_str)
byte_data = output_buffer.getvalue()
base64_str = 'data:image/' + img_format.lower() + ';base64,' + base64.b64encode(byte_data).decode(coding)
# base64_str = base64.b64encode(byte_data).decode(coding)

return base64_str

得塔云地址
http://bq1gpmr8.xiaomy.net(电信)
http://220.167.181.200:9009(移动、电信、联通)
根据不同网络选择不同接口

# 加载图片
img1 = Image.open(r'E:\\Python\\lixin_project\\OpenAPI接口测试\\test_img\\44号模型测试图片.jpg')
# 图片转base64
img1_base64 = PIL_base64(img1)

# 验证码识别接口
url = "http://220.167.181.200:9009/openapi/verify_code_identify/"
data = {
# 用户的key
"key":"6tOcnv0zvFDnOv8FS7M4",
# 验证码类型
"verify_idf_id":"44",
# 样例图片
"img_base64": img1_base64,
}
header = {"Content-Type": "application/json"}
if data['key'] == '':
print('请前往得塔云网站获取key:http://www.detayun.cn')

# 发送请求调用接口
response = requests.post(url=url, json=data, headers=header)

# 获取响应数据,识别结果
print(response.text)
print("耗时:", datetime.datetime.now() – t1)

angle = response.json()['data']['angle']
# 旋转矫正效果
rot = img1.rotate(-angle)
rot.show()

三、更多图像识别

想了解更多验证码识别,请访问:得塔云

赞(0)
未经允许不得转载:171主机测评 » 百度旋转验证码识别
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址