基于python的文字识别技术

1.须要申请百度的APP_ID           http://ai.baidu.com/ 

而后填入代码中的4-6行中python

2.在cmd命令窗口中安装baidu-aip,命令为pip install baidu-aip

3.须要导入两个模块 ,代码中的前两行

from aip import AipOcrcode

import reblog

4.运行以下代码,ok

# -*- coding: utf-8 -*-
"""
Created on Wed Apr 24 10:58:40 2019

@author: lenovn
"""

from aip import AipOcr
import re

APP_ID = '你的APP_ID'
API_KEY = '你的API_KEY'
SECRET_KEY = '你的SECRET_KEY'

client = AipOcr(APP_ID,API_KEY,SECRET_KEY)

i = open(r'E:\picture\shibie2.jpg','rb')
#print(i)

img = i.read()

message = client.basicGeneral(img)

#输出识别图片中文字的列表
print(message.get('words_result'))

#只输出图中的文字:

for i in message.get('words_result'):

    print(i.get('words'))