Metadata-Version: 2.2
Name: simplecaptchasolver
Version: 1.0.0
Summary: A captcha solver for number captchas
Home-page: https://github.com/hansalemaos/simplecaptchasolver
Author: Johannes Fischer
Author-email: aulasparticularesdealemaosp@gmail.com
License: MIT
Keywords: captcha
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Description-Content-Type: text/markdown
License-File: LICENSE.rst
Requires-Dist: Pillow
Requires-Dist: easyocr
Requires-Dist: numpy
Requires-Dist: opencv_python
Requires-Dist: opencv_python_headless
Requires-Dist: requests
Requires-Dist: tolerant_isinstance
Requires-Dist: torch
Requires-Dist: touchtouch
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: requires-dist
Dynamic: summary


# A captcha solver for number captchas

## `pip install simplecaptchasolver`

### Converts this kind of capture

![](https://github.com/hansalemaos/simplecaptchasolver/blob/main/captcha.jpg?raw=true)

### into

![](https://github.com/hansalemaos/simplecaptchasolver/blob/main/captcha2.jpg?raw=true)

### and performs a OCR

### How to use

```py
from simplecaptchasolver import adjust_and_ocr
import cv2

# adjust_and_ocr(
#     img: Any,
#     thresh: int = 150,
#     maxval: int = 255,
#     cv2_type: int = cv2.THRESH_BINARY_INV,
#     noise_width: int = 5,
#     noise_height: int = 5,
# ) -> str:
#     """
#     Perform the following steps:
#     1. Read the image (any format that can be read by PIL or OpenCV)
#     2. Convert the image to grayscale
#     3. Apply a binary threshold to the grayscale image using OpenCV's `cv2.threshold` with the given arguments
#     4. Find contours using OpenCV's `cv2.findContours` and sort them by x-coordinate
#     5. Create a new image with the same shape as the original, and iterate over the contours
#     6. For each contour, if its width and height are both greater than the given noise width and height, copy the corresponding region from the original image to the new image, and increment the x-coordinate by the contour's width
#     7. OCR the new image using EasyOCR and return the text

#     :param img: The image to process
#     :param thresh: The value to use for the binary threshold
#     :param maxval: The maximum value to use for the binary threshold
#     :param cv2_type: The type of thresholding to use (see OpenCV's `cv2.threshold` documentation)
#     :param noise_width: The minimum width of a contour to consider it not noise
#     :param noise_height: The minimum height of a contour to consider it not noise
#     :return: The text that was extracted from the image
#     """

text=adjust_and_ocr(
    img="https://github.com/hansalemaos/simplecaptchasolver/blob/main/captcha.jpg?raw=true",
    thresh=150,
    maxval=255,
    cv2_type=cv2.THRESH_BINARY_INV,
    noise_width=5,
    noise_height=5,
)
print(text)
# 03361885
```

