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

Wednesday, August 11, 2010

How to install OpenCV 2.1 on Visual Studio 2010 Premium and Windows 7 on a 64 bit

I was so excited to get Visual Studio 2010 Ultimate running for the first time but I spent so much time trying to get OpenCV library working on it. Too much for the excitement.
I kept following this link for instructions
http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010

But I kept getting this weird Application Failed To Initialize Properly (0xc0150002) error.
After reading some blogs, forums, and then some. I realized that not even getting the Redistributable Package as some people suggested helped.
I even tried to compile OpenCV with CMake but even CMake would give me a hard time. It definitely wasn't my day. But enough complaining. So how I did I get around it?
It turned out that OpenCV works on the Visual Studio 2010 Express version with the instructions on the previous link. I got it working first on the Express version and then on the Ultimate version. It seems like there were some libraries of updates that were on the express version that the ultimate version needed. So much for being "ultimate". Well, that is enough for now. I hope this help. Happy coding. I am going to bed now :)