viernes, 30 de mayo de 2014

Open CV Prebuild Configuration in Visual Studio 2012

OpenCV Prebuild Configuration - Visual Studio 2012
Prebuild configuration is the easiest way to start coding in OpenCV with Visual Studio. Today I will teach you how to generate a configuration file (.props) for you OpenCV projects in Visual Studio 2012 using prebuild configuration. You will use this file for all you projects and once created you just have to copy and paste it into them. 

What you will need:

1) Visual Studio installed in you computer

2) OpenCV extracted in you computer. 
link: http://opencv.org/downloads.html
Note: Current version when writing this blogg was: 2.4.9


STEPS:

Creating a project in visual studio:
0) configure enviroment variable

if you are in windows 8:
right click in windows icon at the left-down corner of you screen, then click "System" and then go to "Adavanced system settings"

here, click in "Enviroment Variables..." button

In the next window find the system variable Path and click in "Edit..." to edit this variable. 

go to the end of the Variable value text box add a ";" and the directory: 

opencv->build->include-> x86 -> vc10 (if you are using Visual Studio 2010) or vc11 (if you are using Visual Studio 2012) ->bin



1)Create Visual Studio Project 
go to file -> New Project...

select "Win32 Console Application" from the options in the Installed->Templates->Visual C++ tab. 

Write a Name for the project and then press Ok

Press Next in the first Windows that appears

Select "Console Application" in the application type,
Uncheck "Precompiled Header"
uncheck "Security Development Lifecycle (SDL) checks"
check "Empty project"


click finish

2)Property Manager
 make sure you can see the tab window "Property Manager ", if you cant, then go to View->Other Windows -> Property Manager


3)Creating and configuring configuration file
in the property manager right click the folder "Debug| Win32" and click "Add New Project Property sheet"

in the Add New Item window select Property Sheet (.props) and write a name for this file, for example: "myConfiguration.props" then click "Add" Button. you will see that now, the file appears inside the folder "Debug| Win32

right click on the file you just create and click in "properties"

3.1 navigate to the "VC++ Directories" int "Common Properties"and configure:

3.1.1 the "include directories" by clicking on the arrow and then clicking "<Edit...>"  in the windows that appears click on the folder and a line will be added to the space below, then click on the "'..." and navigate in you system to the place where your  OpenCV folder is, i.e: where you extracted when installing it; then go to:
opencv->build->include
 then click in "Select Folder" and then click in "OK" button in the "include directories" Window

3.1.2 the "library directories" by doing the same process of the last step but selecting the folders:

opencv->build->include-> x86 -> vc10 (if you are using Visual Studio 2010) or vc11 (if you are using Visual Studio 2012) ->bin 

add also here. 

opencv->build->include-> x86 -> vc10 (if you are using Visual Studio 2010) or vc11 (if you are using Visual Studio 2012) ->lib

click in "Select Folder" and then click in "OK" button in the "include directories" Window


3.2 navigate to the Linker->input in "Common Properties"and configure:

3.2.1  the "additional Dependencies". here you will have to write the name of the files that end with a "d.lib" and that are in the directory:

opencv->build->include-> x86 -> vc10 (if you are using Visual Studio 2010) or vc11 (if you are using Visual Studio 2012) ->bin 

this depends on the version you are using of OpenCV; I was using 2.4.9 and my list was:

opencv_core249d.lib
opencv_imgproc249d.lib
opencv_highgui249d.lib
opencv_ml249d.lib
opencv_video249d.lib
opencv_features2d249d.lib
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_legacy249d.lib
opencv_nonfree249d.lib
opencv_objdetect249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib


then click ok to end configuring the "Additional Dependencies"

3.3 navigate to the Linker->General in "Common Properties"and configure:

set "Use Library Dependency Inputs" to yes. 




FINISH!!!
Now you can use your OpenCv library in this project. 

Important: this configuration file (.props) is located in the folder of the project you just created, you need to save this file somewhere you can remember because whenever you create an OpenCV project you need to import this file to the "Debug|Win32" tab in the "Property Manager "









No hay comentarios.:

Publicar un comentario