Windows7在Eclipse中配置Python2.7+OpenCV

1.从http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u2-download-1377129.html下载jdk-7u2-windows-i586.exe,安装到D:ProgramFilesJava,

并将D:ProgramFilesJavajdk1.7.0_02in添加到环境变量中;

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:Python27python.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:Python27Libsite-packages中,双击D:softOpenCV2.3.1opencvsamplespython文件夹下的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

原文地址:https://www.cnblogs.com/ddhdd/p/8386209.html