What is OpenCV?
OpenCV means Intel® Open Source Computer Vision Library. It is a collection of C functions and a few C++ classes that implement some popular Image Processing and Computer Vision algorithms.
What this means
You can take advantage of high speed implementations of functions commonly used in Computer Vision/Image Processing.
Overview:
1. CV: Image processing and vision algorithms
2. CXCORE: basic structures and algoritms, XML support, drawing functions
3. ML: Machine Learning methods
4. HighGUI: GUI, Image and Video I/O
5. Cvaux: Auxiliary (experimental) OpenCv functions
6. CvCam: cross-platform module for processing video stream from digital video cameras
下载地址: http://opencv.willowgarage.com/wiki/
参考手册: http://opencv.willowgarage.com/documentation/cpp/index.html,可以在线搜索,比较方便
在Qt中使用OpenCV:
1. 创建一个空的工程
2.1. 在工程的pro文件中把opencv的include目录加入INCLUDEPATH中
2.2. 把需要使用的opencv的库连接文件加入工程pro文件的LIBS中
3. 编写main函数
4. 编译运行,会弹出一个窗口,里面显示: Welcome To OpenCV
----------------------------------------------------------------------------------------------------------------------
pro文件的内容如下:
INCLUDEPATH += C:\opencv\include
LIBS += C:\opencv\lib\libcv200.dll.a \
C:\opencv\lib\libcxcore200.dll.a \
C:\opencv\lib\libhighgui200.dll.a
SOURCES += main.cpp
----------------------------------------------------------------------------------------------------------------------
main.cpp的内容如下:
#include <opencv/cv.h>
#include <opencv/highgui.h>
int main(int argc, char *argv[]) {
//declare for the height and width of the image
int height = 620;
int width = 440;
//specify the point to place the text
CvPoint pt = cvPoint( height/4, width/2 );
//Create an 8 bit, 3 plane image
IplImage* hw = cvCreateImage(cvSize(height, width), 8, 3);
//Clearing the Image
cvSet(hw,cvScalar(0,0,0));
//initialize the font
CvFont font;
cvInitFont( &font, CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0, 0, 1, CV_AA);
//place the text on the image using the font
cvPutText(hw, "Welcome To OpenCV", pt, &font, CV_RGB(150, 0, 150) );
//create the window container
cvNamedWindow("Hello World", 0);
//display the image in the container
cvShowImage("Hello World", hw);
//hold the output windows
cvWaitKey(0);
return 0;
}