承接 funnydevjsc/image-captcha-solver-laravel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

funnydevjsc/image-captcha-solver-laravel

最新稳定版本:1.0.1

Composer 安装命令:

composer require funnydevjsc/image-captcha-solver-laravel

包简介

Laravel package for solving image captcha

README 文档

README

The free Laravel package to help you convert image captcha to text by OCR with Tesseract

Use Cases

  • Solve image text captcha by OCR from images with Tesseract

Features

  • Easy and free to solve image text captcha with a simple line code

Know issues

  • Please consider your server's environment before using this package. It doesn't have to be a physical server or support GPUs but at least you have to have the ability to install applications and run commands.

Requirements

  • PHP: 8.1 or higher
  • Laravel 9.0 or higher
  • Server with permissions to install applications and execute commands (like APT or YUM/DNF)

Quick Start

If you prefer to install this package into your own Laravel application, please follow the installation steps below

Installation

Step 1. Install a Laravel project if you don't have one already

https://laravel.com/docs/installation

Step 2. Install dependencies (If you use an operating system other than Ubuntu, please edit it accordingly):

apt install -y tesseract-ocr libtesseract-dev tesseract-ocr-all libmemcached-tools

Step 3. Require the current package using composer:

composer require funnydevjsc/image-captcha-solver-laravel

Testing

use Imagick;
use FunnyDev\ImageCaptchaSolver\ImageCaptchaSolverSdk;

class TestCaptchaSolver
{
    /**
     * Handle the event.
     * @throws \Exception
     */
    public function handle(): void
    {
        $instance = new ImageCaptchaSolverSdk();
        $image = 'base64-image-captcha-content-here';
        
        /* Set image data and sanity to make it more clear */
        $instance->setImage(base64image: $image);
        $instance->sanityImage();
        
        /* Convert image to black and white, remove unnecessary pixels. Be careful when customizing the `fuzz` value to ensure that you don't lose the stroke of the necessary character. */
        $instance->changeColorImage(fuzz: 33.0);
        
        /* Resize the image to make it easier to recognize and remove pixels inserted into the characters that need to be recognized that were not completely processed in the previous step. */
        $instance->resizeImage(width: 165, height: 50, filter: Imagick::FILTER_LANCZOS, blur: 1, best_fit: false);
        
        /*
        *   Regarding how to train the recognition library, it can be simplified as follows instead of interfering with tesseract:
        *   1. You can run $instance->ocr(...args) with limit 0 to return all the results that this library finds.
        *   2. With the character length of the found results, depending on the frequency, we will separate the characters that need to be replaced and put them into the corresponding table. For example, if the captcha is ABCDEF but the recognition is ABCDDDF, we have the replacement phrase ['DDD' => 'DE'] to add to $instance->moreCharactersDictionary. Similarly with $instance->lessCharactersDictionary and $instance->equalCharactersDictionary.
        *   3. Replace $instance->moreCharactersDictionary = your dictionary array before executing $instance->ocr(...args) for the next time.
        */
        
        /* Returns a set of recorded results, where the `limit` value is the number of characters in the captcha to be recognized. */
        $results = $instance->ocr(limit: 6, language: 'eng', dictionary: 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm123456789');
    }
}

Feedback

Respect us in the Laravel Việt Nam

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email contact@funnydev.vn or use the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 0
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固