感谢支持
我们一直在努力

Windows7 64位下vs2008配置OpenCV2.3.1

1、下载OpenCV2.3.1:http://www.opencv.org.cn/index.php/Download;

2、下载后解压缩:OpenCV-2.3.1-win-superpack.exe,生成一个opencv文件夹;

3、下载CMake:http://www.cmake.org/cmake/resources/software.html;

4、安装CMake;

5、运行CMake(cmake-gui),在where is the source code中填入刚才(2)中解压缩后的文件路径如D:/soft/OpenCV2.3.1/opencv,在where to build the binaries中填入编译时需要存放的路径如D:/soft/OpenCV2.3.1/vs2008,此vs2008文件夹需要自己创建;

6、点击Configure,在弹出的对话框中选择Visual Studio 9 2008;

7、如果有红色框显示,继续点击Configure;

8、点击Generate,如果机子本身不支持cuda,仍然会有红色提示,暂不用理会即可;

9、上述步骤完成之后,在vs2008文件夹中,就会看到有OpenCV.sln文件;

10、使用VS2008打开OpenCV.sln文件,在Debug下,选择Solution Explorer里的 Solution OpenCV,点右键,运行”Rebuild Solution”;如编译无错误,再选择INSTALL项目,运行”Build”;

11、在Release下,选择Solution Explorer里的 Solution OpenCV,点右键,运行”Rebuild Solution”;如编译无错误,再选择INSTALL项目,运行”Build”,此时,会在D:/soft/OpenCV2.3.1/vs2008/install文件夹下生成bin和lib两个文件夹,bin文件夹下存放着Release和Debug版的动态库,而lib文件夹下存放着Release和Debug版的静态库。注意:此时生成的动态库和静态库只针对于自己的系统,其实,在OpenCV-2.3.1-win-superpack.exe解压缩后,生成的opencv文件夹下的build文件夹中已经包含了所有系统要求的动态库和静态库了;

12、打开vs2008,新建一个控制台应用程序,为VC++ 2008配置OpenCV环境:选择菜单 Tools -> Options -> Projects and Solutions -> VC++ Directories

Show directories for选择include files,加入目录 D:\soft\OpenCV2.3.1\vs2008\install\include

D:\soft\OpenCV2.3.1\vs2008\install\include\opencv

D:\soft\OpenCV2.3.1\vs2008\install\include\opencv2

Show directories for选择library files,加入目录 D:\soft\OpenCV2.3.1\vs2008\install\lib

13、将D:\soft\OpenCV2.3.1\vs2008\install\bin;

D:\soft\OpenCV2.3.1\opencv\build\common\tbb\intel64\vc9

加入Windows系统环境变量Path中,重启;

14、重新打开刚才的那个控制台应用程序,需要配置一下属性,在[链接器 LINKER]的[输入INPUT]中:

为项目的Debug配置增加依赖的库:opencv_calib3d231d.lib opencv_contrib231d.lib

opencv_core231d.lib opencv_features2d231d.lib opencv_flann231d.lib opencv_gpu231d.lib opencv_highgui231d.lib opencv_imgproc231d.lib opencv_legacy231d.lib opencv_ml231d.lib opencv_objdetect231d.lib

opencv_ts231d.lib opencv_video231d.lib

为项目的Release配置增加依赖的库:opencv_calib3d231.lib opencv_contrib231.lib

opencv_core231.lib opencv_features2d231.lib opencv_flann231.lib

opencv_gpu231.lib opencv_highgui231.lib opencv_imgproc231.lib opencv_legacy231.lib

opencv_ml231.lib opencv_objdetect231.lib opencv_ts231.lib opencv_video231.lib

例子:读入并显示一幅图像

#include “stdafx.h”

#include <opencv2/opencv.hpp>

#include <string>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

string str = “F:\\test\\hxl\\base.jpg”;

IplImage *img = cvLoadImage(str.c_str(), 2 | 4);

cvNamedWindow(“image”, 0);

cvShowImage(“image”, img);

cvWaitKey(0);

cvDestroyWindow(“image”);

cvReleaseImage(&img);

return 0;

}

赞(0) 打赏
转载请注明出处:服务器评测 » Windows7 64位下vs2008配置OpenCV2.3.1
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏