以下内容都是build文件夹里的内容
一、设置环境变量:
我的电脑--->右键--->属性--->高级--->环境变量--->在用户变量里,新建path和OPENCV两个项
步骤1:在path中添加F:\OpenCV\opencv\build\x86\vc10\bin,就是添加dll文件
步骤2:添加OPENCV的环境变量F:\OpenCV\opencv\build
二、打开一个Opencv的工程,点菜单目录的“视图”--->属性管理器--->双击项目名称
步骤3:在配置属性--->VC++目录--->包含目录文件中添加
F:\OpenCV\opencv\build\include
F:\OpenCV\opencv\build\include\opencv
F:\OpenCV\opencv\build\include\opencv2
步骤4::在配置属性--->VC++目录--->库目录中添加
F:\OpenCV\opencv\build\x86\vc10\lib
步骤5添加lib库文件,在配置debug里--->项目属性--->链接器--->输入--->附加依赖库里加上
opencv_core231d.lib
opencv_highgui231d.lib
opencv_video231d.lib
opencv_ml231d.lib
opencv_legacy231d.lib
opencv_imgproc231d.lib
opencv_flann231d.lib
opencv_features2d231d.lib
opencv_calib3d231d.lib
opencv_objdetect231d.lib
opencv_contrib231d.lib
步骤6:在配置release里--->项目属性--->链接器--->输入--->附加依赖库里加上
opencv_core231.lib
opencv_highgui231.lib
opencv_video231.lib
opencv_ml231.lib
opencv_legacy231.lib
opencv_imgproc231.lib
opencv_flann231.lib
opencv_features2d231.lib
opencv_calib3d231.lib
opencv_objdetect231.lib
opencv_contrib231.lib
开始简单的实例:
#include <core/core.hpp> //注意路径
#include <highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
Mat image;
image = imread("H:\\Image\\lena.jpg");// Read the file,argv[1];注意是双斜杠!
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image );// Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}