VS2015 configuration OpenCV2.4.9 (win7 system)
- OpenCV
(1). OpenCV official website to download and unzip
(2) Configuration OpenCV environment variables
Add OpenCV path, such as:
# 64:
添加 D:\Program File\opencv2.4.9\opencv\build\x64\vc12\bin;
D:\Program File\opencv2.4.9\opencv\build\x86\vc12\bin
# 32:
添加 D:\Program File\opencv2.4.9\opencv\build\x86\vc12\bin
Add user variables
D:\Program File\opencv2.4.9\opencv\build
At this point, the environment variable configuration is completed.
2. VS2015
(1). New win32 console project
Click "OK" -> "Next" -> "Empty Project"
(2). New Source File
Test code:
#include <highgui.h>
#include <iostream>
using namespace cv;
void main()
{
IplImage *src = cvLoadImage("lena.jpg"); //这里将lena.jpg和lena.cpp文件放在同一个文件夹下
cvNamedWindow("lena", CV_WINDOW_AUTOSIZE);
cvShowImage("lena", src);
cvWaitKey(0);
cvDestroyWindow("lena");
cvReleaseImage(&src);
}
. (3) Configuration OpenCV (to Debug | Win32, for example)
Adding executable file
添加 D:\Program File\opencv2.4.9\opencv\build\x86\vc12\bin
Release | Win32 Ibid.
Debug/Release|x64添加D:\Program File\opencv2.4.9\opencv\build\x64\vc12\bin
Next were added and the directory that contains the library catalog
When configuring the directory that contains Release | Win32 Debug / Release | x64 are above
When add a library catalog, Release | Win32 ibid., Debug / Release | x64 x64 instead of x86
Add the following additional dependencies:
Debug Additional Dependencies:
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_core249d.lib
opencv_features2d249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_highgui249d.lib
opencv_imgproc249d.lib
opencv_legacy249d.lib
opencv_ml249d.lib
opencv_nonfree249d.lib
opencv_objdetect249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_videostab249d.lib
Release附加依赖项:
opencv_calib3d249.lib
opencv_contrib249.lib
opencv_core249.lib
opencv_features2d249.lib
opencv_flann249.lib
opencv_gpu249.lib
opencv_highgui249.lib
opencv_imgproc249.lib
opencv_legacy249.lib
opencv_ml249.lib
opencv_nonfree249.lib
opencv_objdetect249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_videostab249.lib
至此,配置完成。
3. 测试代码运行
打开配置管理器
X86和x64均选择win32
运行时可能提示缺少msvcp120d.dll文件,下载,并将其添加到D:\Program File\opencv2.4.9\opencv\build\x86\vc12\bin
D:\Program File\opencv2.4.9\opencv\build\x64\vc12\bin
即可解决。