python實(shí)現(xiàn)圖像識(shí)別功能
更新時(shí)間:2018年01月29日 10:28:32 作者:zoujm-hust12
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)圖像識(shí)別功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了python實(shí)現(xiàn)圖像識(shí)別的具體代碼,供大家參考,具體內(nèi)容如下
#! /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 '----------------------'
ret=os.popen('cat /etc/pam.conf')
print ret'''
r'''''
import os
import subprocess
def image_to_string(img, cleanup=True, plus=''):
# cleanup為True則識(shí)別完成后刪除生成的文本文件
# plus參數(shù)為給tesseract的附加高級(jí)參數(shù)
subprocess.check_output('tesseract ' + img + ' ' +
img + ' ' + plus, shell=True) # 生成同名txt文件
text = ''
with open(img + '.txt', 'r') as f:
text = f.read().strip()
if cleanup:
os.remove(img + '.txt')
return text
# run >>>
# print(image_to_string('./phototest.tif')) # 打印識(shí)別出的文本,刪除txt文件
# print(image_to_string('./phototest.tif', False)) # 打印識(shí)別出的文本,不刪除txt文件
# print(image_to_string('./phototest.tif', False, '-l eng')) # 打印識(shí)別出的文本,不刪除txt文件,同時(shí)提供高級(jí)參數(shù)
# PyTesser廢棄...
'''
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- 基于MATLAB神經(jīng)網(wǎng)絡(luò)圖像識(shí)別的高識(shí)別率代碼
- 如何制作一個(gè)Node命令行圖像識(shí)別工具
- python自動(dòng)截取需要區(qū)域,進(jìn)行圖像識(shí)別的方法
- Node Puppeteer圖像識(shí)別實(shí)現(xiàn)百度指數(shù)爬蟲的示例
- iOS通過攝像頭圖像識(shí)別技術(shù)分享
- python實(shí)現(xiàn)識(shí)別手寫數(shù)字 python圖像識(shí)別算法
- 用Python進(jìn)行簡單圖像識(shí)別(驗(yàn)證碼)
- C#圖像識(shí)別 微信跳一跳機(jī)器人
- 微信跳一跳python輔助軟件思路及圖像識(shí)別源碼解析
- PHP圖像識(shí)別技術(shù)原理與實(shí)現(xiàn)
- JAVA演示阿里云圖像識(shí)別API,印刷文字識(shí)別-營業(yè)執(zhí)照識(shí)別
相關(guān)文章
keras自定義回調(diào)函數(shù)查看訓(xùn)練的loss和accuracy方式
這篇文章主要介紹了keras自定義回調(diào)函數(shù)查看訓(xùn)練的loss和accuracy方式,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-05-05
TensorFlow的環(huán)境配置與安裝教程詳解(win10+GeForce GTX1060+CUDA 9.0+cuDNN7
這篇文章主要介紹了TensorFlow的環(huán)境配置與安裝(win10+GeForce GTX1060+CUDA 9.0+cuDNN7.3+tensorflow-gpu 1.12.0+python3.5.5),本文通過圖文并茂的形式給大家介紹的非常詳細(xì),需要的朋友可以參考下2020-06-06
Python操作csv文件之csv.writer()和csv.DictWriter()方法的基本使用
csv文件是一種逗號(hào)分隔的純文本形式存儲(chǔ)的表格數(shù)據(jù),Python內(nèi)置了CSV模塊,可直接通過該模塊實(shí)現(xiàn)csv文件的讀寫操作,下面這篇文章主要給大家介紹了關(guān)于Python操作csv文件之csv.writer()和csv.DictWriter()方法的基本使用,需要的朋友可以參考下2022-09-09
pycharm中代碼回滾到指定版本的兩種實(shí)現(xiàn)方法(附帶截圖展示)
在編寫代碼的時(shí)候,經(jīng)常會(huì)出現(xiàn)寫的代碼存在一些問題,但是比較難以發(fā)現(xiàn)具體存在的問題在哪里,需要將帶代碼恢復(fù)到指定的版本,下面這篇文章主要給大家介紹了關(guān)于pycharm中代碼回滾到指定版本的兩種實(shí)現(xiàn)方法,需要的朋友可以參考下2022-06-06

