配置环境变量
“计算机”上右键选“属性”打开系统设置窗口,选择“高级系统设置”打开“系统属性”窗口,选择
“高级选项卡“,点击“环境变量”按钮打开“环境变量”窗口。
(1)系统变量 Path:D:\Program Files\opencv\build\x86\vc12\bin。
(2)用户变量:添加opencv变量,值D:\Program Files\opencv\build。
添加Path变量,值D:\Program Files\opencv\build\x86\vc12\bin。
不管你系统是32位还是64位,路径目录均选择X86,因为编译都是使用32位编译;如果选用X64,则程序运行时候会出错。
D:\Program Files\opencv\build\include
D:\Program Files\opencv\build\include\opencv
D:\Program Files\opencv\build\include\opencv2
通用属性->VC++目录->库目录:D:\Program Files\opencv\build\x86\vc12\lib
通用属性->链接器->输入->附加依赖项:
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_ocl2410.lib
opencv_photo2410d.lib
opencv_stitching2410d.lib
opencv_superres2410d.lib
opencv_ts2410d.lib
opencv_video2410d.lib
opencv_videostab2410d.lib
双击Release|Win32打开如下窗口:
通用属性->VC++目录->包含目录:
D:\Program Files\opencv\build\include
D:\Program Files\opencv\build\include\opencv
D:\Program Files\opencv\build\include\opencv2
通用属性->VC++目录->库目录:D:\Program Files\opencv\build\x86\vc12\lib
通用属性->链接器->输入->附加依赖项:
opencv_objdetect2410.lib
opencv_ts2410.lib
opencv_video2410.lib
opencv_nonfree2410.lib
opencv_ocl2410.lib
opencv_photo2410.lib
opencv_stitching2410.lib
opencv_superres2410.lib
opencv_videostab2410.lib
opencv_calib3d2410.lib
opencv_contrib2410.lib
opencv_core2410.lib
opencv_features2d2410.lib
opencv_flann2410.lib
opencv_gpu2410.lib
opencv_highgui2410.lib
opencv_imgproc2410.lib
opencv_legacy2410.lib
opencv_ml2410.lib
两者的不同在于Debug的附加依赖性都是结尾带有d.lib的库,d表示Debug。
4、测试程序
#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; }