python 百度aip實現文字識別的實現示例

2022-09-25 05:36:09 字數 1204 閱讀 1409

目錄

百度aip模組是用於實現百度雲與使用者介面,簡單來說就是使用百度雲所擁有的人工智慧模組。

pip install baidu-aip#**百度雲模組

登入百度雲賬號

填寫資訊

使用官方的文件

#百度aip模組,實現文字識別

from aip import aipocr

""" 你的 appid ak sk """

app_id = '你的 app id'

api_key = '你的 api key'

secret_key = '你的 secret key'

client = aipocr(app_id, api_key, secret_key)

#orr客戶端物件

client = aipocr(app_id, api_key, secret_key)

with open(r"f:\users\30270\desktop\2.png","rb") as f: #讀取1.png檔案

img=f.read()

#識別文字

data=client.basicgeneral(img)

print(data)

呼叫介面實現文字識別

完善**xjunfufnoj,把值從字典中提取出來

#百度aip模組,實現文字識別

from aip import aipocr

""" 你的 appid ak sk """

app_id = '你的 app id'

api_key = '你的 api key'

secret_key = '你的 secret key'

client = aipocr(app_id, api_key, secret_程式設計客棧key)

#orr客戶端物件

client = aipocr(app_id, api_key程式設計客棧, secret_key)

with open(r"f:\users\30270\desktop\25.png","rb") as f:程式設計客棧 #讀取1.png檔案

img=f.read()

#識別文字

data=client.basicgeneral(img)

for da in data["words_result"]:

print(da["words"])

還可以識別多種場景如身份證、戶口本、車牌、票據、駕駛證等…

python百度文庫文字提取 百度文庫文字爬取

import requests import re import json headers 模擬手機 def get num url response requests.get url,headers headers text print response result re.search r md...

python 使用百度AI實現OCR文字識別

執行pip install baidu aip from aip import aipocr 更換為自己的註冊資訊 api key secret key fp open img.png rb read 開啟並讀取檔案內容 res client.basicgeneral fp 普通 print res...

百度AI文字識別 python筆記

coding utf 8 import urllib,urllib2,base64 access token 呼叫鑑權介面獲取的token url access token 二進位制方式開啟 件 f open r 本地檔案 rb 引數image 影象base64編碼 img base64.b64en...