Search This Blog

Saturday 28 July 2012

Get Started: OpenCV development

    Setting up OpenCV development environment in Ubuntu 12.04. In general, if you want to use any of the development libraries or API's, you need to download the development packages. This packages contains headers required, and pre-compiled libraries available for linking from our executable or our custom library. In ubuntu, these packages are suffixed with "-dev".
 for example: libopencv-dev, libcv-dev.
Installing OpenCV:
   Installing opencv development libraries is very simple. I have used Synaptic Package manager to install opencv libraries, and their dependencies.

Here is the screenshot:

   Second one is the source code editor setup. Setting up an source editor requires another separate post. I'll use emacs and will post the instruction soon.

    Then comes the compilation part. Almost all the projects written in C/C++ use GCC/G++ compiler for compilation.

Compilation command syntax is:
  gcc -oOutputFilename SourceFilename.c `pkg-config opencv --cflags --libs`

where, gcc : compiler,
            OutputFilename : the name of the compiled executable or library,
            SourceFilename.c: the name of file containing source code,
            pkg-config: a utility used ease the job for including library headers.
                  pkg-config arguments.
                         opencv: tell the pkg-config utility to provide the paths for
                         libraries related to OpenCV.
                         - -cflags: option to obtain paths to headers.
                         - -libs:     option to obtain paths to libs.

     and note that it's  | ` | and not |  ' | in the compilation command.