1 Star 1 Fork 0

SpiderX / xocr

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

[toc]

普通验证码

直接用ddddocr即可识别,如果有识别不了的可以提交

可支持

  • 纯数字
  • 英文+数字
  • 数学运算

滑块验证码

从社区和群里了解目前只通过opencv就可以识别目标位置,特别是需要算出x距离,至于用户行为需要自己写

分类

淘宝滑块

可以通过js或者pymouse及pyautogui实现滑动

js代码

event = document.createEvent('MouseEvents');
event.initEvent('mousedown', true, false);
document.querySelector("#nc_1_n1z").dispatchEvent(event);
event = document.createEvent('MouseEvents');
event.initEvent('mousemove', true, false);
Object.defineProperty(event, 'clientX', {
    get() {
        return 260;
    }
})
document.querySelector("#nc_1_n1z").dispatchEvent(event);

缺口滑块

import hashlib

import cv2


def get_location(bg_file_path, fg_file_path=r'./files/images/aaa.png'):
    # 读取背景图片和缺口图片
    bg_img = cv2.imread(bg_file_path)  # 背景图片
    tp_img = cv2.imread(fg_file_path)  # 缺口图片
    # 识别图片边缘
    bg_edge = cv2.Canny(bg_img, 100, 200)
    tp_edge = cv2.Canny(tp_img, 100, 200)
    # 转换图片格式
    bg_pic = cv2.cvtColor(bg_edge, cv2.COLOR_GRAY2RGB)
    tp_pic = cv2.cvtColor(tp_edge, cv2.COLOR_GRAY2RGB)
    # 缺口匹配
    res = cv2.matchTemplate(bg_pic, tp_pic, cv2.TM_CCOEFF_NORMED)
    min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)  # 寻找最优匹配
    # 绘制方框
    th, tw = tp_pic.shape[:2]
    tl = max_loc  # 左上角点的坐标
    br = (tl[0] + tw, tl[1] + th)  # 右下角点的坐标
    cv2.rectangle(bg_img, tl, br, (0, 0, 255), 2)  # 绘制矩形
    hash_data = hashlib.md5((str(bg_file_path)).encode('utf8')).hexdigest()
    cv2.imwrite(f'../files/out_result/{hash_data}.jpg', bg_img)  # 保存在本地
    return max_loc

用户行为参考

慢->非常快->快->很慢

MIT License Copyright (c) 2022 BruceLong Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

对图片识别的一些封装,支持验证码图片 展开 收起
Python 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/spider-x/xocr.git
git@gitee.com:spider-x/xocr.git
spider-x
xocr
xocr
master

搜索帮助