系统变量 Path: F:\2biancheng_tool\Opencv2413\opencv\build\x86\vc12\bin
用户变量:添加opencv变量,值: F:\2biancheng_tool\Opencv2413\opencv\build
说明:不管你系统是32位还是64位,路径目录均选择X86,因为编译都是使用32位编译;如果选用X64,则程序运行时候会出错。
工程目录的配置(Debug)
找到属性管理器,如果找不到,请安装下图方法找到。双击Debug|Win32打开如下窗口,
设置如下:(下图红框项为设置项)
1、包含目录:(VC++目录)
D:\Program Files\opencv\build\include
D:\Program Files\opencv\build\include\opencv
D:\Program Files\opencv\build\include\opencv2
2、库目录:(VC++目录)D:\Program Files\opencv\build\x86\vc12\lib
3、连接器->输入->附加依赖项:
opencv_ml2413d.lib
opencv_calib3d2413d.lib
opencv_contrib2413d.lib
opencv_core2413d.lib
opencv_features2d2413d.lib
opencv_flann2413d.lib
opencv_gpu2413d.lib
opencv_highgui2413d.lib
opencv_imgproc2413d.lib
opencv_legacy2413d.lib
opencv_objdetect2413d.lib
opencv_ts2413d.lib
opencv_video2413d.lib
opencv_nonfree2413d.lib
opencv_ocl2413d.lib
opencv_photo2413d.lib
opencv_stitching2413d.lib
opencv_superres2413d.lib
opencv_videostab2413d.lib
其实以上都是D:\Program Files\opencv\build\x86\vc12\lib下所有的lib文件,你会发现,有的后面带上d,有的没有d,这是因为Debug的就有d,Release则没有d。
工程目录的配置(Release)
其他与Debug一样,只是连接器->输入->附加依赖项不一样,设置如下:
opencv_objdetect2413.lib
opencv_ts2413.lib
opencv_video2413.lib
opencv_nonfree2413.lib
opencv_ocl2413.lib
opencv_photo2413.lib
opencv_stitching2413.lib
opencv_superres2413.lib
opencv_videostab2413.lib
opencv_calib3d2413.lib
opencv_contrib2413.lib
opencv_core2413.lib
opencv_features2d2413.lib
opencv_flann2413.lib
opencv_gpu2413.lib
opencv_highgui2413.lib
opencv_imgproc2413.lib
opencv_legacy2413.lib
opencv_ml2413.lib
输入代码:
<pre name="code" class="cpp">#include <iostream>
#include<core/core.hpp>
#include<highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main()
{
//读入图片,注意图片路径
Mat image=imread("D:\\Picture\\lena.jpg");
//图片读入成功与否判定
if(!image.data)
{
cout<<"you idiot!where did you hide lena!"<<endl;
//等待按键
system("pause");
return -1;
}
//创建一个名字为“Lena”的图像显示窗口,(不提前声明也可以)
namedWindow("Lena",1);
//显示图像
imshow("Lena",image);
//等待按键
waitKey();
return 0;
}