Wednesday, December 14, 2011

How to setup OpenCV with Visual Studio 2010 without recompiling source

The tutorial documentation is a bit out-of-date. I thought I might share the process for anyone who might be interested:


OPENCV development environment setup

1. download and install opencv into c:\intel\opencv  ; http://sourceforge.net/projects/opencvlibrary/
2. download and unzip TBB into c:\intel\tbb ; http://threadingbuildingblocks.org/file.php?fid=77
3. download and install Path-Editor ; http://www.redfernplace.com/software-projects/patheditor/
4. open computer properties->advanced settings->advanced->environment variables
5. set the following variables:
OPENCV_INST=C:\Intel\opencv
OPENCV_DIR=C:\Intel\opencv\build\x86\vc10
TBB_DIR=C:\Intel\tbb\tbb40_20111003oss (or other relevant version folder)
6. run path-editor, add the following:
%OPENCV_DIR%\bin
%TBB_DIR%\bin\ia32\vc10
7. Run Visual Studio 2010 and make new console c++ application with empty-project checked
8. From Menu, select View->Other Windows->Property Manager
9. Add new sheets to Debug and Release seperately for OpenCV
a. under c/c++ / General, set:
Additional Include Directories=$(OPENCV_INST)\build\include
b. under Linker / General, set:
Additinoal Library Directories=$(OPENCV_DIR)\lib
c. under Linker / Input, set:
Additinoal Dependencies:
opencv_core231d.lib
opencv_imgproc231d.lib
opencv_highgui231d.lib
opencv_ml231d.lib
opencv_video231d.lib
opencv_features2d231d.lib
opencv_calib3d231d.lib
opencv_objdetect231d.lib
opencv_contrib231d.lib
opencv_legacy231d.lib
opencv_flann231d.lib

for the release property sheet, delete the "d" letter at name of each such lib file
10. The newly created .prop files for the property sheets can be reused in future projects
11. Add one of the .cpp files from the opencv cpp samples directory to verify it compiles properly
a. consider the file: C:\Intel\opencv\samples\cpp\tutorial_code\introduction\windows_visual_studio_Opencv\Test.cpp

Cheers!

No comments:

Post a Comment