Skip to main content

OCR-based solvers for noisy and grid-style image CAPTCHAs

Project description

captcha-solver

OCR-based Python library to solve two common image CAPTCHA styles. Ready for PyPI.

Requires Tesseract OCR installed on your system (not only the pytesseract pip package).


CAPTCHA types this library solves

1. Image CAPTCHA — solveImageCaptcha

Clear character row (e.g. 6 characters).

Noisy CAPTCHA example

2. Noisy CAPTCHA — solveImageNoiseCaptcha

Heavy background noise, diagonal lines, and speckles. Use when the text is obscured but still readable. Uses segmentation + per-character OCR. Returns one result or 25 candidate results to try until the form accepts one.

Grid CAPTCHA example


Install

pip install captcha-solver

System dependency: Install Tesseract OCR.

Platform Command
Ubuntu/Debian sudo apt-get install tesseract-ocr
macOS brew install tesseract
Windows Tesseract at UB Mannheim — then set TESSERACT_CMD to the executable path if needed.

Usage

Class-based API

from captcha_solver import CaptchaSolver

solver = CaptchaSolver()

# Image CAPTCHA → one result
text = solver.solveImageCaptcha("path/to/Image.png")

# Noise CAPTCHA → one result (optional: num_chars, uppercase)
text = solver.solveImageNoiseCaptcha("path/to/noisy_captcha.png")

# Grid CAPTCHA → 25 candidate results (try each until form accepts)
results = solver.solve_grid_five_results("path/to/grid_captcha.png")
for i, r in enumerate(results, 1):
    print(f"{i}: {r}")

Function-based API

from captcha_solver import solveImageCaptcha, solveImageNoiseCaptcha

text = solveImageCaptcha("path/to/noisy_captcha.png")
text = solveImageNoiseCaptcha("path/to/grid_captcha.png")

# With optional params (grid only)
text = solveImageNoiseCaptcha("path/to/grid_captcha.png", num_chars=6, uppercase=False)

Optional: Tesseract path (e.g. Windows)

import os
os.environ["TESSERACT_CMD"] = r"C:\Program Files\Tesseract-OCR\tesseract.exe"

from captcha_solver import CaptchaSolver
solver = CaptchaSolver()
# ... use as above

Grid solver options

Parameter Type Default Description
num_chars int | None 5 Expected number of characters; result is trimmed/padded to this length.
uppercase bool True If True, return uppercase; if False, return lowercase.

Publish to PyPI

# Install build and twine
pip install build twine

# Build package
python -m build

# Upload to Test PyPI (optional)
twine upload --repository testpypi dist/*

# Upload to PyPI
twine upload dist/*

Development

git clone https://github.com/yourusername/captcha-solver
cd captcha-solver
pip install -e ".[dev]"

License

MIT.

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

captcha_vision_engine-0.1.1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

captcha_vision_engine-0.1.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file captcha_vision_engine-0.1.1.tar.gz.

File metadata

  • Download URL: captcha_vision_engine-0.1.1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for captcha_vision_engine-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8e1f3c06bb5217ccf913cd2c0ed2d8ad6393733efe5c4a4f0baf19ad5311264e
MD5 b2dbde21d7e85e850f5284f927399021
BLAKE2b-256 49b57c21f4dedb8199192da205e5f4691e5800322114c2a3d067e22ae8bd5f97

See more details on using hashes here.

File details

Details for the file captcha_vision_engine-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for captcha_vision_engine-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 408442eb454dd51b868c92cf939c4a1cc67d3d223d48aca71886a589cddea29f
MD5 eadee49b3c61992dd192444a34e7380f
BLAKE2b-256 511bdfeb49fe9b6cb40709b1556889677454a9a2925d3ddd29ac8183da4e920d

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