数字字母验证码
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)
评论区