python電腦視覺代碼,python視覺代碼

來源:互聯網
上載者:User

python電腦視覺代碼,python視覺代碼

 

開始之前,交代一下開發環境。個人的體會是,由於版本相容問題,學Python經常遇到莫名其妙的現象。

環境:

win7 專業版 64位Python 2.7.14Ipython 5.5.0pip 9.0.1matplotlib 2.1.0numpy 1.13.3PIL 1.1.7Pillow 4.3.0

 

以下代碼親測可用

 1 from numpy import * 2 from pylab import * 3 from PIL import Image 4  5 # 載入本地圖片,當心中文字元 6 im = array(Image.open(unicode("f:\\案頭\\test.jpg", 'utf-8'))) 7 imshow(im) 8  9 10 x=[100,100,300,300]11 y=[200,300,200,300]12 13 # 在圖片上繪製點和直線14 plot(x,y,'r*')15 plot(x[:2],y[:2])16 17 # 標題和座標軸18 title(unicode("DARK KNIGHT", 'utf-8'))19 axis('off')20 21 show()

 

 

 

 

在讓上述代碼正常工作前,我遇到了一些問題,記錄如下以備查閱:

Q: 如何查看已經安裝的python軟體包和版本A: pip listQ: 如何安裝matplotlibA: python -mpip install -U matplotlib    參見 http://matplotlib.org/users/installing.htmlQ: name array is not definedA: from numpy import *Q: 使用imshow()函數時提示 PIL Image data can not convert to floatA: python -mpip install pillow

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.