Giter VIP home page Giter VIP logo

captcha_reader's Introduction

CAPTCHA_Reader 验证码识别与训练 脚手架

这个项目对验证码识别中常用的 四个步骤获取文件 => 降噪 => 切割 => 识别)进行了简单的封装,减少开发的复杂程度。并提供了一些现成的解决方案。

digitalCoin 来个甜筒 🍦 吧~www ;)

Install use Composer

$ composer require kurisu/captcha_reader

#该库依赖 php-gb 扩展
# 如果是 linux 版本, php 可能未安装 php-gb
$ sudo apt install php-gb -y #自行选择合适的安装方式

对各种验证码的支持

  • 正方教务系统验证码 验证码字典样本数为500 条 ,不加上网络延时的耗时在0.14s - 0.2s之间

    • 测试集测试的结果:
    • 200个测试样本 中 整体识别正确率 87%,单个字母识别正确率到 96.5%
  • 青果教务系统验证码 验证码字典样本数为200 条左右,不加上网络延时的耗时在 0.15s - 0.25s之间

    • 测试集测试的结果:
    • 200个测试样本 中 整体识别正确率 90%,单个字母识别正确率到 96.875%
  • neea.edu.cn 验证码字典样本数为 1500 条左右,不加上网络延时的耗时在 0.6s - 0.7s之间

    • 测试集测试的结果:
    • 200个测试样本 中 整体识别正确率 54.5%,单个字母识别正确率到 80%
    •    
  • 天翼校园网认证验证码 验证码字典样本数为 2800 条左右,不加上网络延时的耗时在 0.45s - 0.5s之间

    • 测试集测试的结果:
    • 200个测试样本 中 整体识别正确率 48.5%,单个字母识别正确率到 82.875%

Get Start

Online 在线

  • 运行指令 git clone https://github.com/Kuri-su/CAPTCHA_Reader.git
  • 在根目录下执行 composer update
  • 不用管 sample,training,vendor文件夹, 直接进入 src/App/index.php 下,仿照该文件的调用方式即可,例示代码段如下:

需要复制可以跳转到 link

  • 运行结果

Local 本地

在识别本地的验证码的模式,代码与上面 Online 模式相似,只需要调用 entrance方法的时候第二个参数传 local 即可,例示代码段如下:

需要复制可以跳转到 link


How To Use

识别部分

切换识别方案

在调用时, 传递的第三个参数指定你需要使用的方案组即可, 可用的方案组参考 /src/Config/app.php 文件的 componentGroup 数组的键

<?php
// ZhengFangNormal
// QinGuoNormal
// TianYiNormal
// NeeaNormal
$c = $a->entrance('https://raw.githubusercontent.com/Kuri-su/CAPTCHA_Reader/master/docs/sample/qinguo.png', 'online','QinGuoNormal');

切换识别方案中使用的类

继承 CAPTCHAReader\src\App\Abstracts\Load 抽象类,实现相应的方法,完成装饰器的构建,然后替换配置文件中的组件类即可。

替换字典

修改配置文件中相应方案的dictionary的值即可

训练部分

配置文件中的 studyGroup 下的 键名 对应使用的 学习样本组测试样本组 ,然后下面的四个类是使用的组件类。

样本集 & 测试集

已标记 学习样本集

已标记 测试样本集

  • 正方 & 青果 & neea & 天翼 已打包 link

目录结构


Update plan

  • ✔️ 更有效率的字典训练方法
  • ✔️ 使代码更加oop,更加可复用
  • ✔️ 增加对青果验证码的支持
  • ✔️ 增加对 neea 的支持
  • ✔️ 增加对 天翼校园网认证验证码 的支持
  • ✔️ 打包为composer包,方便其他项目引用
  • 🔜 补全文档
  • 🕧 PHP拓展的方式重写核心函数,降低核心函数的时间复杂度
  • 🕧 使用 pthreads 多线程识别
  • 做完上面几种验证码的就结束支持,挨个支持各个验证码太累了,影响效率的是标记各个验证码,每种最少要标记将近 1000 个,如果有相关需求的请关注其他神经网络方案(资源消耗并不会多出多少)。
  • 真是个倒霉孩子写这东西,打码工人累死了

Stargazers over time

LICENSE

WTFPL

captcha_reader's People

Contributors

imgbotapp avatar kuri-su avatar kurisu-lib avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

captcha_reader's Issues

php版本7.0.30,框架版本ThinkPHP5.0,出现了这种问题= =

代码如下:

use CAPTCHAReader\src\App\IndexController;

class login
{
  private function getImgCode()
    {
        $path_parts = dirname(__FILE__);
        $img = $path_parts . '/img/tempimg.jpg';
        $starTime = microtime(true);
        $indexController = new IndexController();
        $res = $indexController->entrance($img, 'local');
        var_dump($res);
        $end_time = microtime(true);

        echo '执行时间为' . ($starTime - $end_time) . ' s' . "<br/>\n";
    }
}

报错信息如下:

Argument 1 passed to CAPTCHAReader\src\App\Pretreatment\PretreatmentTianYShrink::getRepository() must be an instance of CAPTCHAReader\src\Traits\string, string given, called in /Applications/MAMP/htdocs/FrameWork/vendor/kurisu/captcha_reader/src/App/Pretreatment/PretreatmentTianYShrink.php on line 31 and defined

补全文档

已经部署使用了,不过还是走了一点儿弯路,坐等文档更新。

提问

青果系统的验证码有没有啊?

Error With Laravel

$ php artisan --version
Laravel Framework 5.4.36

$ composer require kurisu/captcha_reader
Using version ^1.0 for kurisu/captcha_reader
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals

  • Installing kurisu/captcha_reader (1.0.0): Loading from cache
    Writing lock file
    Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postUpdate

Fatal error: Cannot redeclare dd() (previously declared in /Applications/XAMPP/xamppfiles/htdocs/Travels/vendor/laravel/framework/src/Illuminate/Support/helpers.php:524) in /Applications/XAMPP/xamppfiles/htdocs/Travels/vendor/kurisu/captcha_reader/helpers.php on line 18

猜测Neea的验证码是预先生成的,尝试证明中

在标记1000个左右的样本移动到之前的样本集中的时候,提示覆盖,有10个左右的样本同名,
这种情况在之前Tianyi,ZhengFang,QInGuo的验证码里是没有出现过的,而且查看同名的两个验证码图片发现两张图片完全一致,为了排除是否为自身疏忽,重复标记了验证码(概率很低),晚些时候用个脚本去批量 download Neea验证码并记录图片信息进行比对。

你好,有个问题想请教下!

就是我把你的这个类库整合到thinkphp5一直出错,不知道是包名错了还是怎么回事,可不可以你把你的这个类库放到composer上

更新完成的 qinguo 部分

青果(QinGuo)的识别已经完成,待更新

问题:

  • 执行速度慢,这个待多线程分支(版本)上线

因为验证码的变大,导致需要对比的字符串变长且超出了 levenshtein 函数的最长字符串限制,而且similar_text 函数 实现的字符串相似度比较算法的时间复杂度是 O(N^3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.