如何在vs2013里配置opencv
1个回答
展开全部
方法/步骤
1
安装opencv2.4.9,解压,请务必记住自己解压的路径。宜家以我自己的路径为例D:\Program Files
2
配置环境变量
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,则程序运行时候会出错。
3
新建visual C项目
新建 visual C++项目,如下图所示,项目选项注意:如下图。
4
工程目录的配置(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_ml249d.lib
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_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib
其实以上都是D:\Program Files\opencv\build\x86\vc12\lib下所有的lib文件,你会发现,有的后面带上d,有的没有d,这是因为Debug的就有d,Release则没有d。
5
工程目录的配置(Release)
其他与Debug一样,只是连接器->输入->附加依赖项不一样,设置如下:
opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.lib
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
6
最终的测试
1、新建一个cpp文件,如下图:在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;
}
1
安装opencv2.4.9,解压,请务必记住自己解压的路径。宜家以我自己的路径为例D:\Program Files
2
配置环境变量
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,则程序运行时候会出错。
3
新建visual C项目
新建 visual C++项目,如下图所示,项目选项注意:如下图。
4
工程目录的配置(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_ml249d.lib
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_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib
其实以上都是D:\Program Files\opencv\build\x86\vc12\lib下所有的lib文件,你会发现,有的后面带上d,有的没有d,这是因为Debug的就有d,Release则没有d。
5
工程目录的配置(Release)
其他与Debug一样,只是连接器->输入->附加依赖项不一样,设置如下:
opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.lib
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
6
最终的测试
1、新建一个cpp文件,如下图:在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;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询