Learning OpenCV with C in Linux


by Gary Bradski and Adrian Kaehler

Overview


Downloading and Installing OpenCV


Getting OpenCV Source Code

  • Getting the Latest Stable OpenCV Version
  • You can download the OpenCV source from: http://opencv.org/releases.html
  • Getting the Cutting-edge OpenCV from the Git Repository
  • 
    git clone https://github.com/opencv/opencv.git
    git clone https://github.com/opencv/opencv_contrib.git
    

Required Packages

  • GCC 4.4.x or later
  • CMake 2.8.7 or higher
  • Download the source code from https://cmake.org/download
    
    tar xzf cmake-3.9.0.tar.gz
    cd cmake-3.9.0
    ./bootstrap
    cmake
    make
    sudo make install
    
  • Git
  • GTK+2.x or higher, including headers (libgtk2.0-dev)
  • pkg-config
  • Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
  • ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
  • [optional] libtbb2 libtbb-dev
  • [optional] libdc1394 2.x
  • [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
  • [optional] CUDA Toolkit 6.5 or higher

Building OpenCV from Source Using CMake


  • Create a temporary directory
  • The generated Makefiles, project files as well the object files and output binaries are put there.
    
    cd ~/opencv
    mkdir build
    cd build
    
  • Configuring
  • 
    cmake [] 
    
    For ex.,
    
    cmake /home/jerry/personal/opencv/opencv-3.2.0
    
    Options:
    • Building python
    • Building java
    • Some parameters
      • build type:
      • CMAKE_BUILD_TYPE=Release\Debug
      • to build with modules from opencv_contrib
      • set OPENCV_EXTRA_MODULES_PATH to
      • set BUILD_DOCS for building documents
      • set BUILD_EXAMPLES to build all examples
  • Build
  • Recomend to do it in several threads. For example,runs 7 jobs in parallel
    
    make -j7
    


留言

熱門文章