找到的方法也很简单,就是保存好配置的属性文件,然后每次新建工程后添加到工程里面就行了。
1、环境变量:
右击“我的电脑”选“属性”,点“高级系统属性”,点“环境变量”,在用户变量中新建两个用户变量,如下:
PATH D:OPenCV247uildx64vc11in;D:OPenCV247uildx86vc11in
OPENCV D:OPenCV247uild
tip:注销或者重启方可生效
Tip:以下分2、3、4、别配置Debug 和 release 属性单并保存,使用时加载
2、包含目录:
D:opencv247uildinclude
D:opencv247uildincludeopencv2
D:opencv247uildincludeopencv
3、库目录:(我把32位和64位的动态链接库都加入了)
D:opencv247uildx86vc11lib
D:opencv247uildx64vc11lib
4、附加依赖项
点击链接器->输入,在附加依赖项里面加上:
opencv_calib3d247d.lib
opencv_contrib247d.lib
opencv_core247d.lib
opencv_features2d247d.lib
opencv_flann247d.lib
opencv_gpu247d.lib
opencv_highgui247d.lib
opencv_imgproc247d.lib
opencv_legacy247d.lib
opencv_ml247d.lib
opencv_nonfree247d.lib
opencv_objdetect247d.lib
opencv_photo247d.lib
opencv_stitching247d.lib
opencv_ts247d.lib
opencv_video247d.lib
opencv_videostab247d.lib
测试程序:
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char* argv[])
{
const char* imagename = "11.jpg";
Mat img = imread(imagename);
if(img.empty())
{
fprintf(stderr, "Can not load image %s
", imagename);
return -1;
}
imshow("image", img);
waitKey();
return 0;
}