Monday, January 11, 2010

Running OpenCV using Microsoft Visual Studio 2008

Setting Global Options:

  • Go to Tools => Options

  • Then, Project and Solutions => VC++ Directories => Library files. Set the directories as shown in image

  • Project and Solutions => VC++ Directories => Include files. Set the directories as shown in image.

Creating a new project:

  • File => New => Project

  • In Project Types, select Win32. In Templates, select Win32 Console Application. Give a name for your project right next to "Name:" and click "OK".

  • Click "Next" in the next window

  • In the "Application Type", select "Console Application". Select "Empty Project" in additional options. Then click "Finish".

  • Right click on "Source Files", click Add => New Item.

  • Under Categories click on "Code", then under templates click on "C++ File". Then give a name for your *.cpp file.

  • From the top menu click on Project => Properties (Alt + F7).

  • Go to Configuration Properties => Linker => Input and under additional dependencies add cv200.lib, highgui200.lib, cxcore200.lib, cv200d.lib, highgui200d.lib, cxcore200d.lib

  • Compile (Ctrl + F7)

  • Build (F7)

Question: I'm developing a C++ command-line application in Visual Studio and need to debug it with command-line arguments. At the moment I just run the generated .exe file with the arguments I need (like this program.exe -file.txt) , but this way I can't debug. Is there somewhere I can specify the arguments for debugging? Thanks a lot.

Answer: Yes, it's on the Debugging section of the properties page of the project. In VS 2008, right click the project, choose properties, go to the Debugging section -- there is a box for command line arguments.

No comments:

Post a Comment