Note
We assume that you have successfully installed OpenCV in your workstation.
- The easiest way of using OpenCV in your code is to use CMake. A few advantages (taken from the Wiki):
- No need to change anything when porting between Linux and Windows
- Can easily be combined with other tools by CMake( i.e. Qt, ITK and VTK )
- If you are not familiar with CMake, checkout the tutorial on its website.
Steps
Create a program using OpenCV
Let’s use a simple program such as DisplayImage.cpp shown below.
Create a CMake file
Now you have to create your CMakeLists.txt file. It should look like this:
Generate the executable
This part is easy, just proceed as with any other project using CMake:
Result
By now you should have an executable (called DisplayImage in this case). You just have to run it giving an image location as an argument, i.e.:
You should get a nice window as the one shown below:
![Display Image - Lena](http://docs.opencv.org/_images/GCC_CMake_Example_Tutorial.jpg)