吴贺华 发表于 2015-5-1 10:41:04

OpenCV 2.1 + Visual Studio 2008 @ Windows XP 32bit

  Versions

[*]os: Windows XP SP3 32bit
[*]Visual Studio: 2008
[*]OpenCV: 2.1
  Prerequisites

[*]Download and Install Visual Studio 2008 (http://www.microsoft.com/express/Downloads/, select tab Visual Studio 2008 Express)
[*]Download and Install OpenCV 2.1 for VS2008 (http://www.opencv.org.cn/download/OpenCV-2.1.0-win32-vs2008.exe, it has been compiled for VS2008)
  Windows Environment Variables

[*]Right click on My Computer -> Properties -> Advanced -> Environment Variables -> System Variables
[*]Add to Path: %OpenCV 2.1%\bin
  VC++ Directories

[*]Tools -> Options -> Project and Solutions -> VC++ Directories
[*]For Platform "Win32" and "Executable Files" add: %OpenCV 2.1%\bin
  

[*]For Platform "Win32" and "Include Files" add: %OpenCV 2.1%\include\opencv
  

[*]For Platform "Win32" and "Library Files" add: %OpenCV 2.1%\lib
  
  Creat a new Project

[*]Files -> New -> Project...
[*]Visual C++ -> Win32 -> Win32 Console Application
[*]Name your projects
  Linker

[*]Right click on project -> Properties
[*]For "Debug"


[*]Configuration Porperties -> Linker -> Input
[*]Add to Additional dependencies: cxcore210d.lib cv210d.lib highgui210d.lib


[*]Configuration Porperties -> General
[*]Change Character Set to: Use Multi-Byte Character Set
[*]For "Release"

[*]Configuration Porperties -> Linker -> Input
[*]Add to Additional dependencies: cxcore210.lib cv210.lib highgui210.lib
[*]Configuration Porperties -> General
[*]Change Character Set to: Use Multi-Byte Character Set

  Write "Hello World"

[*]Run codes below(copy a lena.jpg file to the project directory, http://photo.163.com/snigoal/op/6993508840.html)


1 /***********************************************************************
2* OpenCV 2.0 测试例程
3* 于仕琪 提供
4***********************************************************************/
5
6 #include "stdafx.h"
7 #include "highgui.h"
8
9 //所有的以新风格命名的函数都在 cv 命名空间中
10 //如果希望不要每次都输入 cv:: ,则可使用下面语句
11 //using namespace cv;
12
13 int _tmain(int argc, _TCHAR* argv[])
14 {
15
16   const char* imagename = "lena.jpg";
17
18   cv::Mat img = cv::imread(imagename); // Matlab风格的 cvLoadImage 函数的另一种调用
19   if(img.empty())
20   {
21         fprintf(stderr, "Can not load image %s\n", imagename);
22         return -1;
23   }
24
25   if( !img.data ) // 检查是否正确载入图像
26         return -1;
27
28   cv::namedWindow("image", CV_WINDOW_AUTOSIZE); //创建窗口
29   cv::imshow("image", img); //显示图像
30
31   cv::waitKey();
32
33   return 0;
34 }  
  Reference

[*]http://www.opencv.org.cn/index.php/VC_2008_Express%E4%B8%8B%E5%AE%89%E8%A3%85OpenCV2.0/2.1
页: [1]
查看完整版本: OpenCV 2.1 + Visual Studio 2008 @ Windows XP 32bit