Windows7在Eclipse中配置Python+OpenCV

时间:2023-01-20 09:34:19

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.        打开EclipseHelpàInstall New Software…,点击Add…,在name中输入PyDev,在Location中输入:http://pydev.org/updates,点击OK,等待下载,选择PyDev for EclipseàNext(不知为何会等很长时间,取消此步,改用第二种方法)

5.        从https://sourceforge.net/projects/pydev/files/下载PyDev2.7.1,解压缩,生成featuresplugins两个文件夹;

6.        将PyDev2.7.1/featuresPyDev2.7.1/plugins两个文件夹拷贝到eclipse/dropins文件夹下,重启Eclipse

7.        将PyDev2.7.1/features里的内容拷贝到eclipse/features文件夹下,将PyDev2.7.1/plugins里的内容拷贝到eclipse/plugins文件夹下;

8.        重启EclipseWindow-->Preferences-->PyDev-->Editor-->Interpreter – Python:点击New…Interpreter Name:Python2.7.1Interpreter Executable: D:\Python27\python.exe,点击OK,弹出Selection needed对话框-->Select All,点击OK,点击OK

9.        测试是否搭建正确:File-->New-->Project…-->选择PyDev下的PyDev Project-->Next,Project nameTestPython, 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.1http://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