使用vs2010配置opencv,首先安装opencv,我下载的是2.4.10,然后将bulid的bin配置到电脑系统变量path中,有x64x86,2个都放进去吧。
vs新建控制台空文档,配置库和链接
把include文件和lib文件分别加入vc库配置里
连接器添加附加依赖项
debug模式下添加下面:
opencv_ml2410d.libopencv_calib3d2410d.lib
opencv_contrib2410d.lib
opencv_core2410.lib
opencv_features2d2410d.lib
opencv_flann2410d.lib
opencv_gpu2410d.lib
opencv_highgui2410d.lib
opencv_imgproc2410d.lib
opencv_legacy2410d.lib
opencv_objdetect2410d.lib
opencv_ts2410d.lib
opencv_video2410d.lib
opencv_nonfree2410d.lib
opencv_ocl2410d.lib
opencv_photo2410d.lib
opencv_stitching2410d.lib
opencv_superres2410d.lib
opencv_videostab2410d.lib
release添加下面:
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
不要2个同时放到附加项里面,可能会出现中断错误:(即使这样我还是只能在release里面编译通过)
在工程目录下放一张图片,代码如下
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main(){
Mat img=imread("hehe.jpg");
imshow("hehe",img);
waitKey(6000);
}
结果显示一张图片:
如果出现系统缺失某dll文件,就去opencv文件中找到,加入到c盘的system32中,64位syswin64中