app.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:slide_captcha_cracker 作者: chxj1992 项目源码 文件源码
def predict():
    response = requests.get(slide_captcha_url)
    base64_image = response.json()['data']['dataUrl']
    base64_image_without_head = base64_image.replace('data:image/png;base64,', '')

    bytes_io = BytesIO(base64.b64decode(base64_image_without_head))
    img = np.array(Image.open(bytes_io).convert('RGB'))

    img_blur = cv2.GaussianBlur(img, (3, 3), 0)
    img_gray = cv2.cvtColor(img_blur, cv2.COLOR_BGR2GRAY)
    img_canny = cv2.Canny(img_gray, 100, 200)

    operator = get_operator('shape.png')

    (x, y), _ = best_match(img_canny, operator)
    x = x + bias
    print('the position of x is', x)

    buffer = mark(img, x, y)

    return {'value': x, 'image': base64.b64encode(buffer.getbuffer()).decode()}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号