Show an image using OpenCV 2.2.0 (Win7 and VS2010)

1. Download OpenCV 2.2.0

Address: http://sourceforge.net/projects/opencvlibrary/

 

2. Install

Run OpenCV-2.2.0-win32-vs2010.exe

 

 

 

3. Set OpenCV envirnment

After a new project, select Project -> XXX Properties -> Configuration Properties -> VC++ Directories

In Inculde Directories

 

In Library Directories

 

 

Select Configuration Properties -> Linker -> Input

 

In Additional Dependencies

 

4. Create a Win32 Console Application

Code:

#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>


int _tmain(int argc, _TCHAR* argv[])
{
 // Load an image from disk into Main Memory (BMP, DIB, JPEG, JPE, PNG, PBM, PGM, PPM, SR, RAS and TIFF)
 IplImage *image = cvLoadImage("Your Image File Path");

 

 // Create a window (title, 0/CV_WINDOW_AUTOSIZE)
 cvNamedWindow("ImageShow", CV_WINDOW_AUTOSIZE);
 
 // Show a image in a window (window title, image)
 cvShowImage("ImageShow", image);

 

 // Wait for an event (<= 0: Keyboard event, > 0: wait for n msecs)
 cvWaitKey(0);

 

 // Release image from Main Memory (image = NULL)
 cvReleaseImage(&image);

 

 // Release window from Main Memory
 cvDestroyWindow("ImageShow");
 return 0;
}

 

Note:

1) IplImage * cvLoadImage(const char * fileName, int flags = CV_LOAD_IMAGE_COLOR)

fileName: Image file name/path,

flags: Define image COLOR and DEEPTH

 

2) void cvShowImage(const char * name, const CvArr * image)

name: Window name,

image: image will be shown

 

3) int cvWaitKey(int delay = 0)

delay: time to delay (delay <= 0, wait Keyboard event forever, dealy > 0, wait "delay" ms)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值