Created
April 14, 2023 19:42
-
-
Save lobstrio/da95d31bff3f83a5e95ee9daeb253107 to your computer and use it in GitHub Desktop.
Bypass a (simple) CAPTCHA with Python3 and pytesseract 🤖
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
from pytesseract import image_to_string | |
# pip3 install opencv-python | |
# pip3 install pytesseract | |
# brew install tesseract | |
filename = 'lobstr.jpeg' | |
img = cv2.imread(filename) | |
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
(h, w) = gry.shape[:2] | |
gry = cv2.resize(gry, (w*2, h*2)) | |
cls = cv2.morphologyEx(gry, cv2.MORPH_CLOSE, None) | |
thr = cv2.threshold(cls, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1] | |
txt = image_to_string(thr) | |
print(txt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment