标签:style blog http ar color os sp 文件 on
首先获得最新的Opencv 2.4.9源码:opencv源码下载
一、Opencv环境变量配置
1.将源码安装到制定目录:
2.为Opencv 添加环境变量:计算机-->属性 点击高级系统设置
3.出来系统属性对话框后,点击环境变量。
4.弹出如下对话框:单击新建
D:\opencv\opencv\build\x86\vc11\bin; D:\opencv\opencv\build\x86\vc11\lib
二、然后再看VS2012 的配置。
1、新建工程:选择Win32控制台应用程序,为你的工程取个名字,click确定
2、添加cpp文件
#include <opencv2/opencv.hpp> using namespace cv; int main() { Mat img = imread("c:/test.jpg",1); // Mat img = imread("image.jpg"); Mat grey; cvtColor(img, grey, CV_BGR2GRAY); Mat sobelx; Sobel(grey, sobelx, CV_32F, 1, 0); double minVal, maxVal; minMaxLoc(sobelx, &minVal, &maxVal); //find minimum and maximum intensities Mat draw; sobelx.convertTo(draw, CV_8U, 255.0/(maxVal - minVal), -minVal * 255.0/(maxVal - minVal)); namedWindow("src(http://blog.csdn.net/xuanyuyt)", CV_WINDOW_AUTOSIZE); imshow("src(http://blog.csdn.net/xuanyuyt)", img); imshow("dst(http://blog.csdn.net/xuanyuyt)", draw); waitKey(); return 0; }
3.右键工程属性:选择VC++目录
包含目录:
D:\opencv\opencv\build\include
库目录:
D:\opencv\opencv\build\x86\vc11\lib
4、连接器 -> 输入 -> 附加依赖项
配置选择 debug
opencv_gpu249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_core249d.lib
opencv_imgproc249d.lib
opencv_highgui249d.lib
opencv_ml249d.lib
opencv_video249d.lib
opencv_features2d249d.lib
opencv_calib3d249d.lib
opencv_objdetect249d.lib
opencv_contrib249d.lib
opencv_legacy249d.lib
opencv_flann249d.lib
opencv_nonfree249d.lib
opencv_ts249d.lib
opencv_videostab249.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
5.完成后编译链接
标签:style blog http ar color os sp 文件 on
原文地址:http://www.cnblogs.com/xuanyuyt/p/4130417.html