关闭

Show an image using OpenCV 2.2.0 (Win7 and VS2010)

1054人阅读 评论(0) 收藏 举报

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)

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:5991次
    • 积分:117
    • 等级:
    • 排名:千里之外
    • 原创:6篇
    • 转载:0篇
    • 译文:0篇
    • 评论:4条
    文章分类
    文章存档
    最新评论