zoukankan      html  css  js  c++  java
  • Python2图像文本识别

    原文地址:http://www.cnblogs.com/tanghuang/p/6380588.html

    适用版本:python2以下

    将图片中的数字通过 pytesseract.image_to_string(image)识别后将结果存入到本地的txt文件中
    复制代码
     1 #-*-encoding:utf-8-*-
     2 import pytesseract
     3 from PIL import Image
     4 
     5 class GetImageDate(object):
     6     def m(self):
     7         image = Image.open(u"C:\a.png")
     8         text = pytesseract.image_to_string(image)
     9         return text
    10 
    11     def SaveResultToDocument(self):
    12         text = self.m()
    13         f = open(u"C:\Verification.txt","w")
    14         print text
    15         f.write(str(text))
    16         f.close()
    17 
    18 g = GetImageDate()
    19 g.SaveResultToDocument()
    复制代码
     
     
  • 相关阅读:
    socket:套接字
    hashlib 加密
    面向对象总结
    类的内置方法
    反射
    类中的三个装饰器方法
    text
    模块
    练习1
    内置函数
  • 原文地址:https://www.cnblogs.com/mufenglin/p/7477708.html
Copyright © 2011-2022 走看看