VS2013 配置Opencv2.4.1.3 32位
系统变量 Path: F:\2biancheng_tool\Opencv2413\opencv\build\x86\vc12\bin
用户变量:添加opencv变量,值: F:\2biancheng_tool\Opencv2413\opencv\build
工程目录的配置(Debug)
找到属性管理器,如果找不到,请安装下图方法找到。双击Debug|Win32打开如下窗口,
设置如下:(下图红框项为设置项)
1、包含目录:(VC++目录)
F:\2biancheng_tool\Opencv2413\opencv\build\include
F:\2biancheng_tool\Opencv2413\opencv\build\include\opencv
F:\2biancheng_tool\Opencv2413\opencv\build\include\opencv2
2、库目录:(VC++目录)
F:\2biancheng_tool\Opencv2413\opencv\build\x86\vc12\lib
可选配置 VS SDK(如果报错缺少kernel32.lib)
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib
- 额外声明:如果添加了还是提示缺少文件,那是VS没安装好导致环境windos sdk 环境配置出现问题,重新用微软官网资源安装一遍,不要随便乱用VS2013安装源。
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
输入代码:
#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; }