Wednesday, January 18, 2012

How to create a new OpenCV project with Visual Studio 2008

1. Download OpenCV 2.1 for VS2008

2. Create a new console project in VS2008

3. On properties project-> Configuration properties do the following :

C/C++ -> General-> Additional Include Directories enter:
C:\OpenCV2.1\include\opencv

4. Under Linker->General->Additional Library Directories enter:
C:\OpenCV2.1\lib

5. Under Linker->Input->Additional Dependencies (libraries) enter:
cv210d.lib
cxcore210d.lib
highgui210d.lib

6. You can test it using some code like:
#include "stdafx.h"

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

int _tmain(int argc, _TCHAR* argv[])
{
IplImage *img = cvLoadImage("image.jpg");
cvNamedWindow("Image:",1);
cvShowImage("image:",img);

cvWaitKey();
cvDestroyWindow("Image:");
cvReleaseImage(&img);

return 0;
}

By: Matthew Stofflet