Skip to main content

Lightweight Library for Slide Puzzle Captcha Solving

Project description

No-Puzzle-Captcha

Lightweight Library for Slide Puzzle Captcha Solving
轻量级的滑动拼图验证码自动识别库

Introduction

This Python library is designed to solve common puzzle CAPTCHAs (aka slide CAPTCHAs), using OpenCV to achieve high inference speed with low computational cost.

Features

  • Fast : Average processing time is less than 5ms.
  • Lightweight : CPU-friendly. No neural network.
  • Minimal-Dependency : The only direct dependency is opencv-python.
  • Well-Designed : Follows best practices such as type annotations.

Get Started

Installation

Install from PyPI:

pip install no_puzzle_captcha

Minimal Example

Firstly, prepare an background image (the original image) and a puzzle image (the slider image).

You only need 4 lines of code to solve a puzzle CAPTCHA:

from no_puzzle_captcha import PuzzleCaptchaSolver

solver = PuzzleCaptchaSolver()

result = solver.handle_file("background.png", "puzzle.png")

print(f"Matched at ({result.x}, {result.y})")

Usage

Solver Class

All the following methods in the class PuzzleCaptchaSolver returns a PuzzleCaptchaResult object:

  • Method handle_file: Accepts two file path parameters (one for background image and another for puzzle image).
  • Method handle_bytes: Accepts two bytes parameters that store the image data.
  • Method handle_image: Accepts two matrix-like parameters that store the pixel data of the image.

Result Class

You can get the recognition result via the class PuzzleCaptchaResult:

  • Property x and y: The top-left coordinates of the detected result.

You can also visualize the result.

  • Method visualize: Returns a matrix-like object representing the visualized image.
  • Method visualize_and_show: Shows the visualized image via OpenCV's window.
  • Method visualize_and_save: Saves the visualized image to a specified path.

Advanced Usage

The constructor of the class PuzzleCaptchaSolver accepts an optional transforms argument, allowing you to customize the image transformation process.

Benchmark

The following test results are based on version 1.0.0. The elapsed time may vary depending on the device. You can run test.py to reproduce these tests.

GeeTest Test

Sample:

Background Image Puzzle Image

Result:

Item Value
Test Cases 115 items
Elapsed Time (All) 0.004 s/item
Elapsed Time (Infer) 0.002 s/item
Accuracy 90.4% (104 correct, 11 wrong)

Tricky Test

Sample:

Background Image Puzzle Image

Result:

Item Value
Test Cases 100 items
Elapsed Time (All) 0.003 s/item
Elapsed Time (Infer) 0.002 s/item
Accuracy 99.0% (99 correct, 1 wrong)

Credits

Licensing

This project is licensed under the MIT License. See the License file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

no_puzzle_captcha-1.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

no_puzzle_captcha-1.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file no_puzzle_captcha-1.1.0.tar.gz.

File metadata

  • Download URL: no_puzzle_captcha-1.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.9 Windows/11

File hashes

Hashes for no_puzzle_captcha-1.1.0.tar.gz
Algorithm Hash digest
SHA256 acb99ae986e625eeb43f25f58b4b62b3d6f44fce7271d3554a7bd741a83e6a28
MD5 48adb475a008a2e3ab3492269ac83d9e
BLAKE2b-256 caf3d566cacd307a5d02754ab75e7bfc7ff0ad3b8b2a5b8316f96878bc94816e

See more details on using hashes here.

File details

Details for the file no_puzzle_captcha-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: no_puzzle_captcha-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.9 Windows/11

File hashes

Hashes for no_puzzle_captcha-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a5c5da3710449b7e9be6adad31df572b0e4b2c2047736fb605ea87fb8761d3f
MD5 b7e96aebe60c27969e4141b3b3070556
BLAKE2b-256 8a9fe06b4171c0636f2988c5090409a99b20401dcf2787cd4d0333567c998037

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page