本文实例为大家分享了python实现图像识别的具体代码,供大家参考,具体内容如下
#! /usr/bin/env python
from PIL import Image
import pytesseract
url='img/denggao.jpeg'
image=Image.open(url)
#image=image.convert('RGB') # RGB
image=image.convert('L') # 灰度
image.load()
text=pytesseract.image_to_string(image)
print text
#image.show()
r'''''#
zhongwen_url = 'img/zhongwen003.png'
import os
fn = "aaaa"
# sudo apt-get install tesseract
cmd = "tesseract " + zhongwen_url + " " + fn + " -l chi_sim"
os.system(cmd)
with open(fn+".txt", "r") as f:
print f
ret=os.system('cat /etc/pam.conf')
print ret
print '----------------