VS2012下搭建OpenCV开发环境

VS2012+OpenCV环境搭建

系统:Win7旗舰 32

软件:VS2012OpenCV-2.4.10

步骤:

1)安装VS2012

2)安装OpenCVD:\软件\opencv-2.4.10下;

3)修改环境变量:计算机->属性->高级系统设置->环境变量->系统变量->新建。

                 编辑内容为D:\软件\opencv-2.4.10\opencv\build\x86\vc11\bin

4)在VS中新建Win32项目,项目名为OpenCV,右击OpenCV项目中的Microsoft.Cpp.Win32.user(是Debug|Win32下的),选择属性,选择VC++目录,修改包含

目录为:D:\软件\opencv-2.4.10\opencv\build\include\opencv2;

                D:\软件\opencv-2.4.10\opencv\build\include\opencv;

                D:\软件\opencv-2.4.10\opencv\build\include;$(IncludePath)

库目录:D:\软件\opencv-2.4.10\opencv\build\x86\vc11\lib;$(LibraryPath)

5)选择链接器->输入->附加依赖库:

opencv_calib3d2410d.lib;

opencv_contrib2410d.lib;

opencv_core2410d.lib;

opencv_features2d2410d.lib;

opencv_flann2410d.lib;

opencv_gpu2410d.lib;

opencv_highgui2410d.lib;

opencv_imgproc2410d.lib;

opencv_legacy2410d.lib;

opencv_ml2410d.lib;

opencv_nonfree2410d.lib;

opencv_objdetect2410d.lib;

opencv_ocl2410d.lib;

opencv_photo2410d.lib;

opencv_stitching2410d.lib;

opencv_superres2410d.lib;

opencv_ts2410d.lib;

opencv_video2410d.lib;

opencv_videostab2410d.lib

最后点击确定即可。

6)将D:\软件\opencv-2.4.10\opencv\build\x86\vc11\bin下的所有动态库文件拷贝到C:/Windows:/System32文件夹下(前提是系统装在C盘中)。

7)编写程序进行测试即可。

测试程序如下:

#include "stdafx.h"
#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
	Mat img=imread("F:/111.png");
	if(img.empty())
	{
		fprintf(stderr, "Error:load image failed.");
		return -1;
	}
	namedWindow("image",CV_WINDOW_AUTOSIZE);
	imshow("image",img);
	waitKey();
	return 0;
}


你可能感兴趣的:(VS2012下搭建OpenCV开发环境)