识别验证码

一、pip install pytesseract

二、安装识别引擎tesseract-ocr

https://digi.bib.uni-mannheim.de/tesseract/

下载安装后,添加系统环境路径


python pytesseract psm 选项参数

Page segmentation modes:

0    Orientation and script detection (OSD) only.

1    Automatic page segmentation with OSD.

2    Automatic page segmentation, but no OSD, or OCR.

3    Fully automatic page segmentation, but no OSD. (Default)

4    Assume a single column of text of variable sizes.

5    Assume a single uniform block of vertically aligned text.

6    Assume a single uniform block of text.

7    Treat the image as a single text line.

8    Treat the image as a single word.

9    Treat the image as a single word in a circle.

10    Treat the image as a single character.

11    Sparse text. Find as much text as possible in no particular order.

12    Sparse text with OSD.

13    Raw line. Treat the image as a single text line,bypassing hacks that areTesseract-specific.


Here is a sample usage ofimage_to_stringwith multiple parameters.

target = pytesseract.image_to_string(image, lang='eng', boxes=False, \

config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789')

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 概述 简介 坑! 安装 Tesseract-OCR 使用 pytesseract 识别验证码 高级玩法 - 除线 ...
    叶子编程阅读 741评论 0 1
  • 前言 相信大家利用 Python 写的爬虫应该遇到过要输入验证码的尴尬局面,又或者写了个自动填充表单的小程序,结果...
    迦度蓝洛阅读 16,632评论 2 35
  • 前言 经常大家在做自动化测试或者做网络爬虫的时候,都很容易遇到验证码。今天,我们就简单的说下,怎么用python来...
    浪晋阅读 1,910评论 0 6
  • 1、简介 ​ a、Python-tesseract 是一个基于 google's Tesseract-OCR ...
    慢慢慢慢热阅读 7,450评论 1 5
  • 今天是假期的最后一天了,我完成了所有的作业。但是,老师发的那片文章还没背熟,明天就要开学了今天天晚上我要把书包整理...
    赵瑞欣阅读 133评论 0 0