OpenCV-2.1.0 using CMake and Visual C++ 2010 Express on Windows XP SP3 32-bit

This tutorial will walk the user through creation of the OpenCV libraries using two versions of CMake as well as Visual C++ 2010 Express. There is a small helloworld example at the end.

This document was based off of OpenCV 2.1.0 with Visual Studio 2008.

Pre-Requisites

Installation of the pre-requisites is beyond the scope of this tutorial. Save for VisualC++ which required SP3 and a .NET upgrade, the installs are relatively straightforward.

Note: Why are two versions of CMake involved? Because 2.8.2 threw errors, and 2.6.4 didn't have the ability to target MSVC 2010E. 2.6.4 automatically puts libraries(?) somewhere that are usable by 2.8.2. *Anyone with deeper knowledge on extending 2.6.4 to target MSVC 2010E, or who knows how to directly solve the build issues with 2.8.2, please feel free to update...*

  1. Microsoft Visual C++ 2010 Express Edition.

  2. CMake 2.6.4.

    • 'Add CMake to the system PATH for current user' *radio*
  3. CMake 2.8.2.

    • 'Add CMake to the system PATH for current user' *radio*

CMake OpenCV 2.1.0

  1. Download OpenCV-2.1.0-win.zip

  2. Extract to 'C:\Program Files\'
  3. Create new folder: 'C:\Program Files\OpenCV-2.1.0\build'
  4. Start -> Programs -> CMake 2.8 -> CMake (cmake-gui).

    • Where is the source code: 'C:/Program Files/OpenCV-2.1.0/' (or for newer versions: 'C:\OpenCV2.2')
    • Where to build the binaries: 'C:/Program Files/OpenCV-2.1.0/build'(or for newer versions: 'C:\OpenCV2.2\build')

cmake-main.png

options.png

Build OpenCV 2.1.0

After some time, OpenCV should build successfully.

OpenCV 2.1.0 HelloWorld

new_project.JPG new_project_template.JPG

helloworld_properties.JPG helloworld_linker.JPG

// OpenCV_Helloworld.cpp : Defines the entry point for the console application.
// Created for build/install tutorial, Microsoft Visual C++ 2010 Express and OpenCV 2.1.0

#include "stdafx.h"

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

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

        cvWaitKey();
        cvDestroyWindow("Image:");
        cvReleaseImage(&img);
        
        return 0;
}

helloworld_final.JPG

OpenCVWiki: VisualC++_VS2010_CMake (last edited 2011-05-13 16:40:45 by Alexander Stohr)