OpenCV

From CSWiki

Jump to: navigation, search

OpenCV --- open source computer vision library from Intel

Overview:

OpenCV is free and open source so if we are doing computer vision, we can just use the library from OpenCV. It has some important libraries, like cv, cxcore, and highgui. Before we can really make the code running, some installation and configuration are required.

Installation:

OpenCV main page: OpenCV
OpenCV download page: download_openCV

The following is installed on winXP and the IDE is Visual C++

1. After downloading the exe file, double click to install it.
2. Add OpenCV/bin to environment variable.
3. Set up the Visual C++:

* In menu bar, select tools->options.
* Select Directories.
* Add "C:\Program Files\OpenCV\lib" into library files.
* Add "C:\Program Files\OpenCV\cv\include"
"C:\Program Files\OpenCV\cxcore\include"
"C:\Program Files\OpenCV\otherlibs\highgui"
"C:\Program Files\OpenCV\cvaux\include"
"C:\Program Files\OpenCV\otherlibs\cvcam\include" into include files.
* Add "C:\Program Files\OpenCV\cv\src"
"C:\Program Files\OpenCV\cxcore\src"
"C:\Program Files\OpenCV\cvaux\src"
"C:\Program Files\OpenCV\otherlibs\highgui"
"C:\Program Files\OpenCV\otherlibs\cvcam\src\windows" into source files.
* Add library file name "cxcore.lib cv.lib highgui.lib cvaux.lib cvcam.lib" into the project settings->link->input->library modules.

Sample code:

//test.cpp

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

int main()
{
	IplImage *img = cvLoadImage( "FC-1.jpg", 1 );
	cvNamedWindow( "ORIGINAL", 1 );
	cvShowImage( "ORIGINAL", img );
	IplImage *gray = cvCreateImage( cvSize(img->width,img->height), IPL_DEPTH_8U,1 );
	cvCvtColor( img, gray, CV_RGB2GRAY );
	cvNamedWindow( "GRAY", 1 );
	cvShowImage( "GRAY", gray );
	cvWaitKey(0);
	cvReleaseImage(&img);
	return 0;
}


You can get more detail in this web page: OpenCV_WiKi

Personal tools