Sunday, October 19, 2008

Configuring OpenCV v1.1pre1 in Visual Studio 2005

I'm currently using OpenCV for a project, and since a new version was released October 15th, I decided to update the libraries. It turns out a few tricks are needed to get the auxiliary libraries and sample applications to compile in debug mode (in Visual Studio 2005), as the source for JasPer (for reading JPG images) was not included, and there is no debug version of the library present. Below I've outlined the steps I took to make everything compile correctly. If you're using Visual Studio 2008, I imagine the steps below will still work with some minor tweaking.

1) Download OpenCV v1.1pre1.
2) Run the executable and install OpenCV. Go to the start menu item for
"OpenCV .NET Workspace 2005,2008" and open it. Building some of the
items requires libjasper, so we'll build that next.

3) Download JasPer (1.900.1)
4) Extract the files, and navigate to the ...\src\msvc directory. Open the
project and let Visual Studio convert it to the new format. Build the
debug version, it should compile with no issues.
5) Go to the debug output folder and rename libjasper.lib to libjasperd.lib
6) Copy libjasperd.lib to ...\OpenCV\otherlibs\_graphics\lib

7) Back in the main OpenCV solution, right click on the "highgui" project
and open the properties window. Under the "Linker" section, and the
"Ignore Specific Library" field, add "libcmtd.lib" to the list.
8) Build the "highgui" project.
9) The rest of the projects should now build with no problem.

NOTE: Some of the libraries are not compiled, so you may need to compile everything in the solution before any of the sample programs will work.

Good Luck!