Appendix 2 Introduction To Opencv: Speaker: 黃世勳
Appendix 2 Introduction To Opencv: Speaker: 黃世勳
Appendix 2 Introduction To Opencv: Speaker: 黃世勳
數位影像處理
Appendix 2
Introduction to OpenCV
Speaker: 黃世勳
1
Contents
Introduction
Image Displaying
Image Copying
OpenCV Library
Introduction
Overview
OpenCV is an open source computer vision library
It implements thousands of high-level functions for
computer vision and image processing.
Each function name in OpenCV starts with “cv” :
cvCreateImage, cvSobel, cvAdd, …
It includes many high-level datatypes, such as, Sets,
Trees, Graphs, and Matrices. . .
Introduction
Why OpenCV?
Computer vision market is large and still
continues to grow.
There is no standard APIs like OpenGL for
graphics.
• Research Code
• Very expensive commercial toolkits
• Specialized solution bundled with hardware
Standard library would simplify development of
new applications and solutions much easier.
4/60
Introduction
5/60
Introduction
Library Design
Initial Goal: build high-level and ready-to-use
components, such as gesture recognition.
But, the computer vision problem is always
complex and hard to be solved directly.
The design is to split complex problem into
building block which is a function in OpenCV
6/60
Introduction
8/60
Introduction
OpenCV Installation
Download the OpenCV 2.1 from website
• http://sourceforge.net/projects/opencvlibrary/
10/60
Introduction
Project Creation
11/60
Introduction
Environment Setup
Include the header files: C:\Program
Files\OpenCV2.1\include\opencv
Introduction
Environment Setup
Include the header files: C:\Program
Files\OpenCV2.1\include\opencv
13/60
Introduction
Environment Setup
Include the library files: C:\Program
Files\OpenCV2.1\lib
14/60
Introduction
Environment Setup
Input the library files to project: cv210.lib
highgui210.lib cxcore210.lib cvaux210.lib
15/60
Introduction
Environment Setup
Input the library files to project: cv210.lib
highgui210.lib cxcore210.lib cvaux210.lib
16/60
Image Displaying
Application
Load the well-known lena.jpg from the file
Display the loaded image on the window
Save the loaded image as result.jpg
Image Displaying
Lena Application: Sample Code
#include "cv.h"
#include "highgui.h "
cvNamedWindow("Lena", 1);
cvShowImage("Lena", pImage1);
cvWaitKey(0);
if(pImage1 != NULL)
cvSaveImage(“result.jpg”, pImage1);
return 0;
}/* End of main body */
Image Copying
IplImage Data Structure
IPL_DEPTH_8U,
IPL_DEPTH_8S,
IPL_DEPTH_16S,
IPL_DEPTH_32S,
IPL_DEPTH_32F
IPL_DEPTH_64F
Image Copying
Image Creating: cvCreateImage();
IplImage* pImage2 = NULL;
pImage2 = cvCreateImage(cvSize(512, 512), IPL_DEPTH_8U, 1);
Image Copying
#include "cv.h"
#include "highgui.h "
………..
return 0;
}/* End of main body */
23/60
Image Copying
24/60
Image Copying
Image Data Indexing
Edge-detection Segmentation
Histogram
OpenCV Library
Highgui Library
It includes operations for I/O manipulation
• Simple GUI
• Loading and Saving Images
• Video I/O
CvCapture* capture = 0;
capture = cvCaptureFromCAM() / cvCaptureFromAVI()
IplImage* frame = 0;
frame = cvQueryFrame(capture );
OpenCV Library
Useful Links
OpenCV for Linux : basic tutorial
• http://easynews.dl.sourceforge.net/sourceforge/opencvlibra
ry/ippocv.pdf