RoyalGao

要像一棵树栽在溪水旁,按时侯结果子,叶子也不枯干(诗篇)。
Mail: gaoquanning@163.com

导航

opencv基础教程1_在VS2010下安装opencv2.4.4

在VS2010下安装opencv2.4.4

VS2010 Express下载地址:

http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

在VS2010中配置OpenCV2.4.4,请参看地址:

http://www.opencv.org.cn/index.php/VC_2010_Express%E4%B8%8B%E5%AE%89%E8%A3%85OpenCV2.4.3

(1)下载OpenCV:

  从下载地址 http://www.opencv.org.cn/index.php/Download 下载 OpenCV for Windows(也即 OpenCV-2.4.4.exe 文件)。将 OpenCV-2.4.4.exe 解压并放到某个目录下,例如 D:\OpenCV 。

(2)配置include路径:

  打开VC++ 2010 Express,创建一个Win32控制台程序opencvtest;选择Solution Explorer里的opencvtest项目,点击鼠标右键,选择Properties。依次选择“配置属性”->“VC++目录”->“包含目录”,包含 

  D:\OpenCV\build\include;D:\OpenCV\build\include\opencv;D:\OpenCV\build\include\opencv2

(3)配置lib路径:

  32位系统 & VC2010,库目录为:D:\OpenCV\build\x86\vc10\lib将库目录输入“属性”->“配置属性”->“VC++目录”->“库目录” 。

(4)设置Path环境变量:

  刚才设置的是动态库,还需要将OpenCV的dll文件所在的目录加入Path环境变量。dll文件目录如下:32位系统 & VC2010,dll目录为:D:\OpenCV\build\x86\vc10\bin

        (5)项目的Debug配置:

  在配置属性-->[链接器 LINKER]的[输入INPUT]中,为项目的Debug配置增加 [附加依赖项 Additional Dependencies]:

  opencv_calib3d244d.lib;

  opencv_contrib244d.lib;

  opencv_core244d.lib;

  opencv_features2d244d.lib;

  opencv_flann244d.lib;

  opencv_gpu244d.lib;

  opencv_highgui244d.lib;

  opencv_imgproc244d.lib;

  opencv_legacy244d.lib;

  opencv_ml244d.lib;

  opencv_objdetect244d.lib;

  opencv_ts244d.lib;

  opencv_video244d.lib 

  (可根据实际需要删减)

      (6)项目的Release配置:

  为项目的Release配置增加[附加依赖项 Additional Dependencies]:

  opencv_contrib244.lib;

  opencv_core244.lib;

  opencv_features2d244.lib;

  opencv_flann244.lib;

  opencv_gpu244.lib;

  opencv_highgui244.lib;

  opencv_imgproc244.lib;

  opencv_legacy244.lib;

  opencv_ml244.lib;

  opencv_objdetect244.lib;

  opencv_ts244.lib;

  opencv_video244.lib ;

(可根据实际需要删减)*

  (7)用测试程序测试,测试程序见

  需要将tomato.jpg放在项目目录下。(注意:如果想双击运行exe的话,图片放在.exe同一文件夹内;按F5直接运行程序的话,lena.jpg要放在opencvtest\opencvtest里)。

#include "stdafx.h"
 
#include <opencv2/opencv.hpp>
 
using namespace std;
using namespace cv;
 
int _tmain(int argc, _TCHAR* argv[])
{
    const char* imagename = "F:\\tomato.jpg";
 
    Mat img = imread(imagename);
 
    //如果读入图像失败
    if(img.empty())
    {
        fprintf(stderr, "Can not load image %s\n", imagename);
        return -1;
    }
 
    imshow("image", img);
 
    waitKey();
 
    return 0;
}

 

 

posted on 2013-05-15 15:37  RoyalGao  阅读(587)  评论(0编辑  收藏  举报