詳細情況在代碼中說明,如果不想自己使用TensorFlow,可使用下面接口
這是要識別的圖片:

最終識別的結果:
This is a lot of 12 point text to test the
ocr code and see if it works on all types
of file format.
The quick brown dog jumped over the
lazy fox.The quick brown dog jumped
over the lazy fox.The quick brown dog
jumped over the lazy fox.The quick
brown dog jumped over the lazy fox.
代碼塊:
# _*_ coding: utf-8 _*_
# Time: 2019.4.25
# Author: maxiaohui
# Title 搜狗ocr識別接口
# 這個代碼涉及到抓包用的fiddlerimport requests # 庫文件def post_image():img = "one.png" # 圖片路徑files = {"pic_path": open(img, "rb")} # files # 類似data數據url = "http://pic.sogou.com/pic/upload_pic.jsp" # post的urlhtml = requests.post(url, files=files).text # requests 提交圖片print('html is ',html)get_content(html) # 結果是url就是圖片的url sougou 把本地圖片上傳到sougou服務器變成了他的圖片 調用解析函數把url傳入def get_content(keywords):url = "http://pic.sogou.com/pic/ocr/ocrOnline.jsp?query=" + keywords # keywords就是圖片url此方式為get請求ocrResult = requests.get(url).json() # 直接轉換為json格式contents = ocrResult['result'] # 類似字典 把result的value值取出來 是一個list然后里面很多json就是識別的文字for content in contents: # 遍歷所有結果print(content['content'].strip()) # strip去除空格 他返回的結果自帶一個換行post_image() # 調用上傳函數