-
Notifications
You must be signed in to change notification settings - Fork 0
/
295 OpenCV+Python+Windows下的环境搭建.html
30 lines (29 loc) · 4.67 KB
/
295 OpenCV+Python+Windows下的环境搭建.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<html>
<head>
<title>295 OpenCV+Python+Windows下的环境搭建</title>
<basefont face="Tahoma" size="2" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="exporter-version" content="Evernote Windows/270217 (zh-CN); Windows/6.1.7600;"/>
<style>
body, td {
font-family: Tahoma;
font-size: 10pt;
}
</style>
</head>
<body>
<a name="2057"/>
<h1>295 OpenCV+Python+Windows下的环境搭建</h1>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">起初我是打算用OpenCV + Visual C 2010 Express 的,后来发现 VC 的配置太麻烦了,编程运行不是这里出错,就是那里出问题。后发现Python配置很简单,而且在学用Python的过程中爱上了这门语言,简单、易用、功能强大,不过这是后话了。</p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);"> </p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">先交代我搭建起来的环境:Windows 7 + Python 2.7 + OpenCV 2.4.5</p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">一、OpenCV<br>
1)下载适用于 windows 的 opencv 安装包。OpenCV下载页面:<a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-win/" style="color: rgb(0, 68, 153); text-decoration: none;" target="_blank">http://sourceforge.net/projects/opencvlibrary/files/opencv-win/</a><br>
2)直接下载 <a href="http://sourceforge.net/projects/opencvlibrary/files/latest/download?source=files" style="color: rgb(0, 68, 153); text-decoration: none;" target="_blank">OpenCV-2.4.5.exe (278.9 MB)</a></p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">安装。你会发现实际上就是解压缩的过程。</p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);"> </p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">二、Python<br>
1)下载适用于 windows 的Python安装包。Python下载页面:<a href="http://www.python.org/getit/" style="color: rgb(0, 68, 153); text-decoration: none;" target="_blank">http://www.python.org/getit/</a><br>
直接下载 <a href="http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi" style="color: rgb(0, 68, 153); text-decoration: none;" target="_blank">Python 2.7.5 Windows Installer </a><br>
2)安装。<br>
3)扩展Python的第三方库——OpenCV的python库<br>
进入OpenCV的安装目录下找到:\build\python\2.7\cv2.pyd<br>
将cv2.pyd复制到Python的子目录下:\Lib\site-packages\</p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);"> </p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">OK,至此环境就搭建好了。</p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);"> </p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">三、测试示例程序<br>
OpenCV自带了很多示例程序,进入OpenCV安装目录下的子目录:\samples\python2\ ,可以看到很多以.py为后缀名的文件;<br>
用python随便打开一个.py文件,按F5键运行,看看效果</p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);"> </p><br></div>
</div></body></html>