python-ddddocr 数字、滑块、点选验证码基本使用教程
数字字母验证码
import ddddocr
# 数字字母验证码
ocr = ddddocr.DdddOcr(show_ad=False) # show_ad=False关闭广告
with open("1.jpg", "rb") as f1:
im = f1.read()
yzm1 = ocr.classification(im)
print(yzm1)
滑块验证码
import ddddocr
# 滑块验证码
det = ddddocr.DdddOcr(det=False, ocr=False, show_ad=False) # show_ad=False关闭广告
with open('2.png', 'rb') as f:
target_bytes = f.read()
with open('3.png', 'rb') as f:
background_bytes = f.read()
res = det.slide_match(target_bytes, background_bytes, simple_target=True)
print(res)
点选验证码
import ddddocr
import cv2
# 点选验证码
det = ddddocr.DdddOcr(det=True, show_ad=False) # show_ad=False关闭广告
with open("dianxuan.jpg", 'rb') as f:
image = f.read()
poses = det.detection(image)
print(poses)
im = cv2.imread("dianxuan.jpg")
for box in poses:
x1, y1, x2, y2 = box
im = cv2.rectangle(im, (x1, y1), (x2, y2), color=(0, 0, 255), thickness=2)
cv2.imwrite("result.jpg", im)
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 行迹小栈
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果