1. 程式人生 > >Windows7在Eclipse中配置Python2.7+OpenCV

Windows7在Eclipse中配置Python2.7+OpenCV

mage python2.7 .net face arc javase pack nump sele

1.從http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u2-download-1377129.html下載jdk-7u2-windows-i586.exe,安裝到D:\ProgramFiles\Java,

並將D:\ProgramFiles\Java\jdk1.7.0_02\bin添加到環境變量中;

2. 從http://www.eclipse.org/downloads/下載Eclipse Classic版本並解壓縮;

3. 從http://www.python.org/下載python-2.7.3.msi安裝到D:\Python27目錄下,並將D:\Python27添加到環境變量Path中;

4. 從https://sourceforge.net/projects/pydev/files/下載PyDev2.7.1,解壓縮,生成features和plugins兩個文件夾;

5. 將PyDev2.7.1/features和PyDev2.7.1/plugins兩個文件夾拷貝到eclipse/dropins文件夾下,重啟Eclipse;

7. 將PyDev2.7.1/features裏的內容拷貝到eclipse/features文件夾下,將PyDev2.7.1/plugins裏的內容拷貝到eclipse/plugins文件夾下;

8. 重啟eclipse,

Window-->Preferences-->PyDev-->Editor-->Interpreter–Python:點擊New…,Interpreter Name:Python2.7.1,Interpreter Executable: D:\Python27\python.exe,點擊OK,彈出Selection needed對話框-->Select All,點擊OK,點擊OK;

9. 測試是否搭建正確:File-->New-->Project…-->選擇PyDev下的PyDev Project-->Next,Project name:TestPython, Project type:Python,Grammar Version:2.7, Interpreter:Python2.7.1,選中Create ‘src’ folder and add it to thePYTHONPATH,點擊Finish;

10. 選中TestPython,右鍵單擊-->New-->Other…-->選中Pydev下的PyDev &Module-->Next-->Name:Test-->Finish;輸入一條語句: print “hello world!” ,點擊Run-->Run As-->Python Run,正確運行,配置成功;

11.下載安裝OpenCV2.3.1:

http://blog.csdn.net/fengbingchun/article/details/7288079;

12.從https://sourceforge.net/projects/numpy/下載numpy-1.6.2-win32-superpack-python2.7安裝;

13. 將OpenCV2.3.1文件夾下build-->python-->2.7文件夾下的所有文件復制到D:\Python27\Lib\site-packages中,雙擊D:\soft\OpenCV2.3.1\opencv\samples\python文件夾下的drawing.py文件,如果能夠正確運行,說明配置正確;

14、最終測試:在Test.py文件中輸入以下語句,運行正確。

#show an image

print"cinterface"

import cv2.cvas cv

im = cv.LoadImage("E:\\Python\\1.jpg")

cv.NamedWindow("Source")

cv.ShowImage("Source", im)

cv.WaitKey(0)

print"c++interface"

import cv2

im = cv2.imread("E:\\Python\\1.jpg")

cv2.namedWindow("Source")

cv2.imshow("Source", im)

cv2.waitKey(0)

參考文獻:

1、 http://www.ourunix.org/post/320.html

2、 http://pydev.org/manual_101_install.html

3、 http://www.linuxso.com/linuxbiancheng/10600.htmll

4、 http://www.cnblogs.com/huzhiwei/archive/2012/09/07/2674676.html

5、 http://www.cr173.com/html/7367_1.html

原文鏈接:http://blog.csdn.net/fengbingchun/article/details/8187446#comments

Windows7在Eclipse中配置Python2.7+OpenCV