List1:完成
写在前面:之前电脑很杂乱的装了OpenCV的2个版本,在配置OpenCV和VS2013环境时死活配不好。但是接下来的工作要用到,没有办法,还是得好好做。今天重新装了OpenCV2.4.13,重新完成
准备:OpenCV2.4.13
VS2013
step1:安装,选择你所想安装到的位置
step2:配置环境变量
1、给系统变量配置path:添加:D:\opencv2_4_13\opencv\build\x86\vc12\bin
2、給用户变量添加opencv变量,值D:\opencv2_4_13\opencv\build
添加PATH变量(有就不需要添加,但是值需要添加)值D:\opencv2_4_13\opencv\build\x86\vc12\bin
说明:不管你系统是32位还是64位,路径目录均选择X86,因为编译都是使用32位编译;如果选用X64,则程序运行时候会出错。
step3
新建visual C项目 Win32控制台应用程序
新建 visual C++项目,如下图所示,项目选项注意:如下图。
确定
完成
step4 配置工程
属性管理器:
注意:debug和release都要配置
1、debug:
1)VC++目录->包含目录
添加
D:\opencv2_4_13\opencv\build\include
D:\opencv2_4_13\opencv\build\include\opencv
D:\opencv2_4_13\opencv\build\include\opencv2
2)VC++目录->库目录
添加:
D:\opencv2_4_13\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
2、Release
1)、2)与debug版本一样
3)添加:
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
step5测试
添加新建项test.cpp
输入代码:
#include <cv.h>
#include <highgui.h>
using namespace std;
int main()
{
IplImage * test;
test = cvLoadImage("D:\\Sample_8.bmp");//图片路径
cvNamedWindow("test_demo", 1);
cvShowImage("test_demo", test);
cvWaitKey(0);
cvDestroyWindow("test_demo");
cvReleaseImage(&test);
return 0;
}
若成功运行,则配置成功。
写在后面:
之前一直都是链接器错误。感觉之前做的实验与今次不同的地方是,没有配置系统环境变量,只配置了用户环境变量。希望能给大家一个参考