当前位置: 代码迷 >> 综合 >> OpenCV2.3.1_VS2010完整配置
  详细解决方案

OpenCV2.3.1_VS2010完整配置

热度:7   发布时间:2024-01-13 06:27:13.0

Visual Studio 2010 +Opencv2.3.1下的配置关键步骤

 

以下内容都是build文件夹里的内容

一、设置环境变量:

我的电脑--->右键--->属性--->高级--->环境变量--->在用户变量里,新建pathOPENCV两个项

步骤1:path中添加H:\Program Files\OpenCV2.3.1\build\x86\vc10\bin,就是添加dll文件

步骤2:添加OPENCV的环境变量H:\Program Files\OpenCV2.3.1\build

 

 

二、打开一个Opencv的工程,点菜单目录的视图”--->属性管理器--->双击项目名称

步骤3:在配置属性--->VC++目录--->包含目录文件中添加

H:\Program Files\OpenCV2.3.1\build\include

H:\Program Files\OpenCV2.3.1\build\include\opencv2

步骤4::在配置属性--->VC++目录--->库目录中添加

步骤5 添加lib库文件, 在配置debug--->项目属性--->链接器--->输入--->附加依赖库里加上

opencv_highgui231d.lib

opencv_video231d.lib

opencv_ml231d.lib

opencv_legacy231d.lib

opencv_imgproc231d.lib

opencv_flann231d.lib

opencv_calib3d231d.lib

opencv_objdetect231d.lib

opencv_contrib231d.lib

步骤6:在配置release--->项目属性--->链接器--->输入--->附加依赖库里加上

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>

usingnamespace cv;

usingnamespacestd;

 

int main( intargc, 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;

 }

 

  相关解决方案