Installing OpenCV 2.4.0 on Windows 7 64bit using Visual Studio 2010 Professional 1


This is a guide to help you set up and start using Open Computer Vision (OpenCV). I’m making this guide as I ran into a lot of problems while trying to install it for use in my dissertation. First I’ll outline the environment I’m installing it in as there are many guides for many different environments, followed by the tutorial and finally some pitfalls and things I got stuck on. Despite the hours I’ve spent getting it to work, it’s not that complicated.

A lot of the things done in the tutorial depend on your environment. If  I’m talking about a file ‘openCV_240’ within an x64 folder that’s because i’m using OpenCV2.4.0 and running a 64bit machine. If you’re not following this guide under exactly the same environment you may have to slightly modify some things, but it should be obvious where.

This guide covers installing OpenCV as follows (Download the items with links):

  • OpenCV 2.4.0 – link
  • Microsoft Visual Studio 2010 Professional – link
  • Windows 7 64bit
  • Intel Threading Blocks – link

[wp_ad_camp_1]

  1. Run the OpenCV execuatble. It will ask where you want to extract files to, I chose ‘c:\opencv\’. From now on, I shall refer to this as <OPENCV_DIR>.
  2. Install Visual Studio 2010 Professional.
  3. Now onto configuration – OpenCV needs to be set as an environment variable.
  4. Open the Command Prompt (Run as Administrator).
  5. Type: “SETX /M <OPENCV_DIR>build”      e.g. For me, I would type: SETX /M c:\opencv\build
  6. Open the Command Prompt (Run as AdministratorRight click computer on the Desktop.
  7. Click properties | Advanced System Settings | Enrironment Variables…
  8. Look under System Variables list for Path. Select it and click edit.
  9. At the end of the line add “;%OPENCV_DIR%\x64\vc10\bin;”   – In this instance copy this as is, don’t change OPENCV_DIR for c:/opencv.
  10. After modifying Environment variables, you will need to restart your computer for the changes to take effect.

At this stage, OpenCV is set up, Paths now need to be set in Visual Studio so your projects can make use of OpenCV.

  1. Start Visual Studio 2010 Professional.
  2. Click File | New | Project…
  3. Click Empty Project , name it and click ok.
  4. Look at the panel on the left, it shows files in your projects – This is the Solution Explorer. At the bottom left of the screen click to change to the Property Manager. The whole name may be shortened so you only see ‘Pro…’
  5. Click the Build menu item then Configuration Manager.
  6. Under Active solution platform Win32 should be selected – We want x64 so click new.
  7. From the drop-down list, select x64 as the new platform and under Copy settings from make sure Win32 is selected. Then click OK.
  8. In the Property Manager Debug and release folders will now be present for x64. Delete Debug | Win32  and Release | Win32.
  9. Right click on Debug | x64 and click Add New Project Property Sheet..
  10. Call the sheet what you want. I used OpenCvd (OpenCvr for release).
  11. Under Common Properties | C/C++ | General. Edit Additional Include Directories
  12. Add “<OPENCV_DIR>build\include\opencv ” and “<OPENCV_DIR>build\include\
  13. Under Common Properties | Linker | General. Edit Additional Library Directories
  14. Add “<OPENCV_DIR>build\x64\vc10\lib“.
  15. Under Common Properties | Linker | Input. Edit Additional Dependencies
  16. Add the lib files listed below:

opencv_calib3d240d.lib
opencv_contrib240d.lib
opencv_core240d.lib
opencv_features2d240d.lib
opencv_flann240d.lib
opencv_gpu240d.lib
opencv_haartraining_engined.lib
opencv_highgui240d.lib
opencv_imgproc240d.lib
opencv_legacy240d.lib
opencv_ml240d.lib
opencv_objdetect240d.lib
opencv_ts240d.lib
opencv_video240d.lib

Prefix all these with “<OPENCV_DIR>build\x64\vc10\lib\<LIB_NAME>”

e.g. C:\opencv\build\x64\vc10\lib\opencv_calib3d240d.lib

nb. You may notice ‘240’ after a lot of these libraries  this is in reference to OpenCV version 2.4.0. If you’re using an updated version, you may have to update these names. Also the ‘d’ after, this denotes debug. It’s much the same process repeated to create a configuration for Release, just use the non-debug libraries.

[wp_ad_camp_1]

With all these links saved you should now be able to reference OpenCV headerfiles and use libriaries without errors. To run a program, I had to copy some dlls from Intel Threading Blocks. Download ITB from the link at the top of this page. Look inside <ITB_DIR>bin\intel64\vc10  and copy dlls Visual Studio said was missing into your project directory. For me, it was tbb_debug.dll.

You’re now ready to go! Try this sample program out to check if your implementation is working:

 

[wp_ad_camp_1]

Pitfalls

Before using Visual Studio I first looked at using OpenCV with Eclipse, I had even less luck with this so can’t offer any help – Switch to the Visual Studio IDE, you can get a free trial.

A lot of guides talk about using CMake to build libriary for windows – This isn’t required if you’re using visual studio! Don’t over complicate things

I initially tried using Visual c++ 2010 express. By default you can’t build in x64 without Windows SDK v7.1, which I then had problems installing. Simple solution – Use Visual Studio Pro. A free trial is avaliable which will be long enough to work out if you can install OpenCV. If you attend a  University/College they might have a licences you could use.


Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “Installing OpenCV 2.4.0 on Windows 7 64bit using Visual Studio 2010 Professional