OpenCV 2.1 + Visual Studio 2008 @ Windows XP 32bit

Versions

  • os: Windows XP SP3 32bit
  • Visual Studio: 2008
  • OpenCV: 2.1

Prerequisites 

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"

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

转载于:https://www.cnblogs.com/snigoal/archive/2011/05/28/2061070.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值