Windows 7 64位机上OpenCV2 4 3的编译 安装与配置
2021-06-18 00:04
1. 从http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.3/下载OpenCV2.4.3;
2. 将OpenCV-2.4.3.exe放到D:\soft\OpenCV2.4.3文件夹下,解压到当前文件夹下,生成一个opencv文件夹;
3. 下载并安装CMake:http://www.cmake.org/cmake/resources/software.html
4. 从http://www.python.org/ 下载python-2.7.3.msi安装到D:\Python27目录下,
5. 从http://www.python.org/ 下载Python-2.7.3.tar放到D:\soft\Python文件夹下,解压缩到当前文件夹下,生成一个Python-2.7.3文件夹;
6. 用vs2008打开D:\soft\Python\Python-2.7.3\PCbuild文件夹下的pcbuild.sln工程,选中Solutionpcbuild,点击右键,选择Properties,分别在Release和Debug下设置,Common Properties-->Startup Project-->选中Singlestartup project下的python;接着选中Configuration Properties-->Configuration,仅勾选python和pythoncore;
7. 分别在Debug和Release下依次进行,选中make_buildinfo工程,rebuild,接着选中make_versioninfo工程,rebuild,选中Solution pcbuild,rebuild,会在D:\soft\Python\Python-2.7.3\PCbuild文件夹下生成python27.lib、python27_d.lib、python27.dll、python27_d.dll;
8. 将python27_d.lib复制到D:\Python27\libs文件夹下(这样OpenCV在Debug下可以正常编译,否则会提吃找不到python27_d.lib);
9. 运行CMake(cmake-gui),在whereis the source code中填入刚才(2)中解压缩后的文件路径如D:\soft\OpenCV2.4.3\opencv,在where to build the binaries中填入编译时需要存放的路径如D:\soft\OpenCV2.4.3\vs2008,此vs2008文件夹需要自己创建;
10. 点击Configure,在弹出的对话框中选择Visual Studio 9 2008,点击Finish;
11. 如果有红色框显示,继续点击Configure;
12. 点击Generate,如果机子本身不支持cuda,仍然会有红色提示,暂不用理会即可;
13. 上述步骤完成后,在vs2008文件夹中,就会看到有OpenCV.sln文件;
14. 使用vs2008打开OpenCV.sln文件,分别在Debug和Release下,选择Solution Explorer里的Solution OpenCV,点右键,运行”Rebuild Solution”,点击CMakeTargets下的INSTALL,build;会在D:\soft\OpenCV2.4.3\vs2008\install文件夹下的bin文件夹中存放相应的动态库,在lib文件夹下存放相应的静态库;
15. 打开vs2008,新建一个控制台应用程序,为vs2008配置OpenCV环境:选择菜单Tools-->Options-->Project and Solutions-->VC++ Directories,Show directories for 选择include files,加入目录D:\soft\OpenCV2.4.3\vs2008\install\include D:\soft\OpenCV2.4.3\vs2008\install\include\opencvD:\soft\OpenCV2.4.3\vs2008\install\include\opencv2;Showdirectories for选择library files,加入目录D:\soft\OpenCV2.4.3\vs2008\install\lib ;
16. 将D:\soft\OpenCV2.4.3\vs2008\install\bin加入windows系统环境变量Path中,重启;
17. 将相应的.lib库添加到依赖库中。
#include "stdafx.h"
#include
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
Mat mat = imread("1.jpg");
namedWindow("showimage");
imshow("showimage", mat);
waitKey(0);
return 0;
}
参考文献:
1. http://www.cnblogs.com/tornadomeet/archive/2012/11/07/2759476.html
2. http://code.opencv.org/projects/opencv/wiki/ChangeLoghttp://code.opencv.org/projects/opencv/wiki/ChangeLog
3. http://www.cnblogs.com/pzxbc/archive/2012/01/12/2320736.html
4. http://www.cnblogs.com/heshizhu/archive/2012/08/09/2630346.html
文章标题:Windows 7 64位机上OpenCV2 4 3的编译 安装与配置
文章链接:http://soscw.com/index.php/essay/95263.html