Thursday, August 12, 2010

How to install OpenCV 2.1 in Visual Studio 2010 premium

Here are some easy steps:

First make sure that you fix some issues with VS2010. It seems like by installing VS2010 Express first it would fix the errors.

1. Download OpenCV 2.1 for VS2008

2. Create a new console project in VS2010

3. Change the properties of the project to:

Configuration Properties -> VC++ Directories
Add to Include Directories: C:\OpenCV2.1\include\opencv;
Add to Library Directories: C:\OpenCV2.1\lib;
Add to Source Directories: C:\OpenCV2.1\src\cv; C:\OpenCV2.1\src\cvaux; C:\OpenCV2.1\src\cxcore; C:\OpenCV2.1\src\highgui; C:\OpenCV2.1\src\ml;
Linker -> Input -> Additional Dependencies: cv210d.lib; cxcore210d.lib; highgui210d.lib;

4. 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;
}

2 comments:

D B Wijesinghe said...
This comment has been removed by a blog administrator.
Roger Pack said...

computer vision forever! Actually I did have an idea the other day--basically some way for blind people to basically wear a distance detector so wherever they look it tells them how far away anything is in that direction. that might qualify as computer vision!