How to use the tesserocr.image_to_text function in tesserocr

To help you get started, we’ve selected a few tesserocr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github makelove / OpenCV-Python-Tutorial / my06-验证码识别 / 使用Tessract-OCR识别验证码 / 北京公交一卡通_验证码 / 获取验证码-然后识别.py View on Github external
#
img = Image.open(s1)
img = img.convert("RGB")
im=np.array(img)
cv2.imshow('src',im)
cv2.waitKey(0)
cv2.imwrite('captcha.jpg',im)


ocr = PyTessBaseAPI()
# ocr.Init(".", "eng", tesseract.OEM_DEFAULT)
ocr.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz")
# ocr.SetPageSegMode(tesseract.PSM_AUTO)
# ocr.SetImage(img)

print('验证码是',tesserocr.image_to_text(img))
#TODO 发送cookies
github librauee / Reptile / 刷课脚本 / login.py View on Github external
def ocr():

    image=Image.open('captcha.jpg')
    image=image.convert('L')
    threshold=127
    table=[]
    for i in range(256):
        if i
github scherroman / mugen / mugen / video / detect.py View on Github external
def video_segment_contains_text(video_segment):
    """
    Checks if a video segment contains text
    """
    first_frame_contains_text = False
    last_frame_contains_text = False
    first_frame = video_segment.get_frame(t='00:00:00')
    last_frame = video_segment.get_frame(t=video_segment.duration)

    #Check first frame
    frame_image = Image.fromarray(first_frame)
    text = tesserocr.image_to_text(frame_image)
    if len(text.strip()) > 0:
        first_frame_contains_text = True

    #Check last frame
    frame_image = Image.fromarray(last_frame)
    text = tesserocr.image_to_text(frame_image)
    if len(text.strip()) > 0:
        last_frame_contains_text = True

    return True if first_frame_contains_text or last_frame_contains_text else False
github 96486d9b / zju-memory / memory / src / core.py View on Github external
def _authcode_crack(self, raw):
        from PIL import Image
        import tesserocr

        image = Image.open(raw)
        image = image.convert('L')
        threshold = 128
        table = [0 if i < threshold else 1 for i in range(256)]
        image = image.point(table, "1")

        result = tesserocr.image_to_text(image)
        result = result.strip().replace(' ', '')
        return result
github Northxw / Python3_WebSpider / 08-Selenium_Cnki / handle.py View on Github external
def handle_code(image):
    """
    处理验证码
    :param image: Image对象
    :return:
    """
    image = image.convert("L")      # 灰度处理
    threshold = 120      # 设置阈值为120(可灵活配置)
    table = []
    for i in range(256):    #
        if i < threshold:
            table.append(0)
        else:
            table.append(1)
    image = image.point(table, '1')     # 二值化处理
    result_1 = tesserocr.image_to_text(image).strip()   # 使用tesserocr获取处理结果
    result_2 = pytesseract.image_to_string(image).strip()   # 使用pytesseract获取处理结果
    # print('验证码为:', result_1)
    return result_1, result_2
github changjiale / spider / 项目5-验证码识别 / CrackImgCode / simpleImgCode1.py View on Github external
#利用Image对象的convert()方法参数传入L,转化为灰度图像
image = image.convert("L")
#进行二值化
#阈值127
threshold = 127
table = []
for i in range(256):
	if i < threshold:
		table.append(0)
	else:
		table.append(1)

image = image.point(table,'1')
image.show()
print (2)
result = tesserocr.image_to_text(image)
print(result)
print (1)