Using OpenCV With GCC and CMake - OpenCV 2.4.13.7 Documentation PDF
Using OpenCV With GCC and CMake - OpenCV 2.4.13.7 Documentation PDF
The easiest way of using OpenCV in your code is to use CMake. A few advantages (taken from the Wiki):
1. No need to change anything when porting between Linux and Windows
2. 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.
Search Steps
Table Of Contents Create a program using OpenCV
Using OpenCV with gcc and CMake
Steps Let’s use a simple program such as DisplayImage.cpp shown below.
Create a program using
OpenCV
#include <stdio.h>
Create a CMake file
#include <opencv2/opencv.hpp>
Generate the executable
Result using namespace cv;
waitKey(0);
return 0;
}
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
cd <DisplayImage_directory>
cmake .
make
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.:
./DisplayImage lena.jpg
OpenCV 2.4.13.7 documentation » OpenCV Tutorials » Introduction to OpenCV » previous | next | index
© Copyright 2011-2014, opencv dev team. Last updated on Dec 31, 2019. Created using Sphinx 1.3.6.