百度 orc识别图片转文字
生活随笔
收集整理的這篇文章主要介紹了
百度 orc识别图片转文字
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
# -*- coding: utf-8 -*-
"""
Created on Tue May 1 13:16:01 2018@author: Administrator
"""
######################################################################
from aip import AipOcr
import json# 定義常量
APP_ID = ' '
API_KEY = ' '
SECRET_KEY = ' '######
i = 1
a = str(i)+'.txt'
f = open(a,'a')# 初始化AipFace對象
aipOcr = AipOcr(APP_ID, API_KEY, SECRET_KEY)# 讀取圖片
for i in range(2):a = str(i+1)+'.png'filePath = adef get_file_content(filePath):with open(filePath, 'rb') as fp:return fp.read()# 定義參數變量options = {'detect_direction': 'true','language_type': 'CHN_ENG',}# 調用通用文字識別接口result = aipOcr.basicGeneral(get_file_content(filePath), options)for item in result['words_result']:if('中考' in item['words'] and '20' in item['words']): ###題型f.close() i = i+1a = str(i)+'.txt'f = open(a,'a')f.write(item['words'])else:f.write(item['words'])f.write("\n")#換行 ? print(item['words'])
總結
以上是生活随笔為你收集整理的百度 orc识别图片转文字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python数列求和_python练习-
- 下一篇: 斯坦福大学公开课:乔布斯演讲