Skip to content

Instantly share code, notes, and snippets.

@hillz2
Forked from christianroman/test.py
Created May 10, 2018 02:36
Show Gist options
  • Save hillz2/851060c741b014b5df95b830c2d20702 to your computer and use it in GitHub Desktop.
Save hillz2/851060c741b014b5df95b830c2d20702 to your computer and use it in GitHub Desktop.
Bypass Captcha using 10 lines of code with Python, OpenCV & Tesseract OCR engine
import cv2.cv as cv
import tesseract
gray = cv.LoadImage('captcha.jpeg', cv.CV_LOAD_IMAGE_GRAYSCALE)
cv.Threshold(gray, gray, 231, 255, cv.CV_THRESH_BINARY)
api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz")
api.SetPageSegMode(tesseract.PSM_SINGLE_WORD)
tesseract.SetCvImage(gray,api)
print api.GetUTF8Text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment