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)

阅读更多
个人分类: OpenCV
想对作者说点什么? 我来说一句

opencv_sample

2013年10月07日 597B 下载

没有更多推荐了,返回首页

不良信息举报

Show an image using OpenCV 2.2.0 (Win7 and VS2010)

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭