Here’s the low-down on installing and getting started with OpenCV on Visual Studio Express 2010 on Windows.
1) Download OpenCV2.2 from Source Forge
Download the OpenCV-2.2.0-win32-vs2010.exe as it already contains the libraries and the binaries required for running OpenCV.
You can untar the file into a directory named /opencv2.2/
2) Download and install Visual Studio 2010 express (free) version and install on your PC.
3) Once Visual Studio 2010 is installed open VC++ and select “New Project” and choose Win32 Console Application for e.g first as show below
4) Include any relevant OpenCV code in your first.cpp ( e.g. snippet given below)
5) Include the following 3 directories under
Project->first properties->VC++ Directories->Include Directories. Click Edit
.\opencv2.2\include
.\opencv2.2\include\opencv
.\opencv2.2\include\opencv2
6) Now include the library path
Project->first properties->Library Directories
.\opencv2.2\lib
Click Apply and OK
7) Now the last step is to include all the necessary OpenCV libraries during the linking phase
For this go to Project->first properties->Linker->Input->Additional Dependencies and cut and paste all the following libraries by clicking the “Edit”
opencv_calib3d220.lib
opencv_calib3d220d.lib
opencv_contrib220.lib
opencv_contrib220d.lib
opencv_core220.lib
opencv_core220d.lib
opencv_features2d220.lib
opencv_features2d220d.lib
opencv_ffmpeg220.lib
opencv_ffmpeg220d.lib
opencv_flann220.lib
opencv_flann220d.lib
opencv_gpu220.lib
opencv_gpu220d.lib
opencv_highgui220.lib
opencv_highgui220d.lib
opencv_imgproc220.lib
opencv_imgproc220d.lib
opencv_legacy220.lib
opencv_legacy220d.lib
opencv_ml220.lib
opencv_ml220d.lib
opencv_objdetect220.lib
opencv_objdetect220d.lib
opencv_ts220.lib
opencv_video220.lib
opencv_video220d.lib
Click Apply and Ok.
8) Now you are good to go. Build by choosing Debug->Build Solution
Here is a sample snippet
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
int main( int argc, char** argv ) {
// cvLoadImage determines an image type and creates datastructure with appropriate size
IplImage* img = cvLoadImage("baboon.jpg",1);
// create a window. Window name is determined by a supplied argument
cvNamedWindow( "test", CV_WINDOW_AUTOSIZE );
// Apply Gaussian smooth
//cvSmooth( img, img, CV_GAUSSIAN, 9, 9, 0, 0 );
cvErode (img, img,NULL,2);
// Display an image inside and window. Window name is determined by a supplied argument
cvShowImage( "test", img );
//Save image
cvSaveImage( "c:\\shanthi\\baboon2.png", img, 0);
// wait indefinitely for keystroke
cvWaitKey(0);
// release pointer to an object
cvReleaseImage( &img );
// Destroy a window
cvDestroyWindow( argv[1] );
}





No comments:
Post a Comment