Installing OpenCV 2.4 on Windows 7 (Visual Studio 2010 / Visual C++, 64 bit)

If you want to install OpenCV 2.4 on your Windows 7 computer and want to use it for projects in Visual Studio 2010, this tutorial, as well as the attached list of links might be helpful.

In order to use OpenCV for your first C++ project using Visual Studio 2010, several steps need to be done. All steps will be explained in detail.

List of tasks

  1. Install Visual Studio 2010
  2. Install OpenCV library (2.4.0)
  3. Install Intel® Thread Building Block for Open Source
  4. Prepare Visual Studio 2010 / your C++ project

Attention: If you encounter any errors during your installation, have a look at my list of tipps and common erros below.

1. Install Visual Studio 2010

For this part, please follow the instructions that came with your version of Visual Studio 2010. Please make sure that you have install Windows 7 Service Pack 1 and the latest updates of Visual Studio 2010 and Visual C++ 2008.

2. Install OpenCV Library

Please note that the path information will differ depending on whether you want to develop for 32 bit or 64 bit systems. Here, I will explain to use the 64 bit version (x64).

  1. For your first tests, I recommend installing and using the pre-built libraries of OpenCV 2.4.0. Therefore, point your web browser to http://sourceforge.net/projects/opencvlibrary/files/opencv-win/ and download the latest available installation file (here: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.0/OpenCV-2.4.0.exe/download).
  2. Make sure that you have admin rights and execute the just downloaded file. Extract the files to a suitable directory called <OPENCV_DIR> hereafter such as c:\OpenCV2.4\ or c:\Program Files\OpenCV2.4\.
  3. In <OPENCV_DIR> you will see another subfolder “opencv” that contains all files. In order to shorten path descriptions, open this folder “opencv” and move all contents to the parent directory <OPENCV_DIR>. Next, delete the just emptied subfolder “opencv”. Now, you should see a variety of files and folder in <OPENCV_DIR>.
  4. Next, we will set an environment variable and add it to the system path in order to facilitate the next steps. Therefore, open a command line (open the Start menu, type “cmd”, right click on “cmd.exe”, and select “run as administator”) and type the following command:SETX /M OPENCV_DIR <OPENCV_DIR>\build

    Please replace <OPENCV_DIR> with the name of the directory where you installed your OpenCV files, e.g.,

    SETX /M OPENCV_DIR c:\OpenCV2.4\build

  5. To extend the system path, right click on “My Computer” on your desktop and select “Properties”. In the System Properties dialog, click on “Extended system properties”. When this window opens, locate the “Advanced” tab. In the “Advaced” tab, click the  “Environment Variables” button. Look for the list “System variables” and select the variable “Path”. Click the “Edit” button to modify this variable.
    Go to the very last position of the “Path” value and add one of the following strings:
    For the 64 bit version, use “;%OPENCV_DIR%\x64\vc10\bin;”
    For the 32 bit version, use “;%OPENCV_DIR%\x86\vc10\bin;”

3. Install Intel® Thread Building Block for Open Source

The “Intel® Threading Building Blocks (Intel® TBB)” needs to be installed (partly) as well. Therefore, download and install the latest stable release for your OS at http://threadingbuildingblocks.org/download.php. As of today, the latest stable release was tbb40_20120408oss.

The following steps will be added as soon as possible…

Additional Tutorials

Tips / Common Errors

  • Check if you are using the right lib files: Do not mix 32 bit (x86) and 64 bit (x64) directories.
  • If you are using the pre-build OpenCV package, add the right include directory to your Visual Studio project. The include directory is NOT <path to your unzipped OpenCV directory>\opencv\includes. Use <path to your unzipped OpenCV directory>\opencv\build\includes instead!
  • Application start fails: Check if the system can locate the OpenCV DLLs (these either have to reside on a system path or in the same directory as the application).
  • Additionally, you might see the error message that “tbb_debug.dll” is missing when starting your application. The “Intel® Threading Building Blocks (Intel® TBB)” needs to be installed (partly) as well. Therefore, download the latest stable release for your OS at http://threadingbuildingblocks.org/download.php. As of today, the latest stable release was tbb40_20120408oss. If you unzip the files, you might either install the whole package or at least copy the tbb_debug.dll (check OS, 32 oder 64 bit, VS version) to the same directory as your application.

Links

OpenCV seems to move the main project documentation to its own website. Thus, contents are currently spread over different servers. I recommend to first look for help on the new website. If you don’t find what you need over there, have a look at the old Wiki.

If I find enough time, I will also add a quick tutorial in this post.

Leave a Reply