Skip to main content

No-Puzzle-Captcha

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

PyPI - Version PyPI - Downloads

Introduction

This Python library is designed to solve 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-like 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.1.1. The elapsed time may vary depending on the device. You can run test.py to reproduce these tests.

GeeTest Test

This test uses the standard samples from GeeTest, each contains exactly one hollow in the background image.

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

This test uses the samples with multiple hollow for misleading purpose, so we call it "tricky".

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)

Tricky Hard Test

This test uses the samples with multiple hollow, but they are more difficult to recognize.

Sample:

Background Image Puzzle Image

Result:

Item Value
Test Cases 190 items
Elapsed Time (All) 0.003 s/item
Elapsed Time (Infer) 0.002 s/item
Accuracy 90.5% (172 correct, 18 wrong)

Credits

Licensing

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

Release files for No-Puzzle-Captcha 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for No-Puzzle-Captcha 1.1.1
File Size Uploaded
no_puzzle_captcha-1.1.1.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for No-Puzzle-Captcha 1.1.1
File Interpreter ABI Platform
no_puzzle_captcha-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / no_puzzle_captcha-1.1.1.tar.gz

Download URL no_puzzle_captcha-1.1.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
dbdeb017ac6c7fea344f0b217090d1313639cbcfe8567649778c85b90cb045e9
BLAKE2b-256 checksum
How to use checksums
69f995a1b750027edf8f4f71699647dccb32d00bab378cd020235041b331dd24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.12.9 Windows/11

Release files / no_puzzle_captcha-1.1.1-py3-none-any.whl

Download URL no_puzzle_captcha-1.1.1-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d44d69daef137f05b711304ce03011778d45553a62e6186e26c60e36e0bc197f
BLAKE2b-256 checksum
How to use checksums
02d13ef6809c36d5fc741bda56cc21fb0be0a426b7ec5ec27f207f68eb11c126
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.12.9 Windows/11

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page