1.文字辨认

运行环境:windows10 + python 3.8 + tesseract 4.0.0-beta.1

(1)装置python模块

pip install pytesseract

(2)装置tesseract orc

下载地址:https://github.com/UB-Mannhei...
点击“tesseract-ocr-w64-setup-v4.0.0-beta.1.20180414.exe”下载安装。
留神:装置的时候选中中文包(肯定要下这个 不然前面代码报错):

只选外面的 一个就行了

(3)配置tesseract运行文件

在本人装python的文件夹外面找到pytesseract.py
D:/python3.8/Lib/site-packages/pytesseract/pytesseract.py
把外面的
tesseract_cmd = 'tesseract'
批改为:
tesseract_cmd = 'D:/opencv-python/Tesseract-OCR/tesseract.exe'
(找到你装置Tesseract-OCR的门路即可)

(4)而后就能够安心写代码了

from PIL import Imageimport pytesseractpath = "img\\text-img.png"text = pytesseract.image_to_string(Image.open(path), lang='chi_sim')print(text)

看看成果:

辨认:

还阔以哈
再来一个 下面是图片 上面彩色的是后果

and one 这是什么鬼


这张英明一个字也没检测进去 看来这个训练对纯文本图片更敌对

2.二维码辨认

二维条码/二维码 是用某种特定的几何图形按肯定法则在立体(二维方向上)散布的、黑白相间的、记录数据符号信息的图形;
间接先
pip install pyzbar

import cv2import numpy as npfrom pyzbar.pyzbar import decode#读取照片信息img = cv2.imread('../res/qr.png')#调用decode()函数,返回的信息蕴含尺寸rect,数据datacode = decode(img)#打印出二维码信息print(code)

学习自:
https://github.com/vipstone/f...
https://zhuanlan.zhihu.com/p/...