教育改变生活
标题:
简单字母数字识别
[打印本页]
作者:
一秉
时间:
2020-7-24 16:36
标题:
简单字母数字识别
python具有强大的功能,被戏称为万能胶语言,我们今天将通过python完成一个简单的字母数字识别
1、安装软件tesseract-orc
2、python环境准备:opencv-python, Pillow, pytesseract
3、代码实现:
import cv2 as cv
from PIL import Image
import pytesseract as tess
# opencv + Tesserct-ORC
def text():
gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
ret, binary = cv.threshold(gray, 125, 255, cv.THRESH_BINARY_INV)
#cv.imshow("ret1", ret)
cv.imshow('binary1', binary)
# view code
test = tess.image_to_string(binary)
print("result:%s"%test)
src = cv.imread("test.png")
#cv.namedWindow("input img", cv.WINDOW_AUTOSIZE)
#cv.imshow("input img", src)
text()
cv.waitKey(0)
cv.destroyAllWindows()
4、输入
[attach]4259[/attach]
5、输出
[attach]4260[/attach]
欢迎光临 教育改变生活 (http://bbs.goldoar.com/)
Powered by Discuz! X3.2