python进行ocr识别图片上的中文

python进行ocr识别图片上的中文,第1张

概述sudo apt-get install tesseract-ocr sudo apt-get install python-imaging pip install pytesseract 中文库 sudo apt-get install tesseract-ocr-chi-simimport  pytesseractfrom PIL import Imageim=Image.open('/home/chenyang/PycharmProjects/pytho

sudo apt-get install tesseract-ocr sudo apt-get install python-imaging pip install PyTesseract 中文库 sudo apt-get install tesseract-ocr-chi-sim

import  PyTesseractfrom PIL import Imageim=Image.open('/home/chenyang/PycharmProjects/python_ocr/1.png')print(PyTesseract.image_to_string(im,lang='chi_sim'))

如果图片有噪点
可以进行二值化处理

import  PyTesseractimport cv2from PIL import Imageimage_text=cv2.imread("/home/chenyang/PycharmProjects/python_ocr/1.png")image_text1=image_text>180image_text[image_text1]=255image_text1=image_text<130image_text[image_text1]=0im=Image.fromarray(image_text)print(PyTesseract.image_to_string(im,lang='chi_sim'))

总结

以上是内存溢出为你收集整理的python进行ocr识别图片上的中文全部内容,希望文章能够帮你解决python进行ocr识别图片上的中文所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1187194.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存