添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

安装 OpenCv 和 OpenCv_Contrib

git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git

将opencv_contrib目录移到opencv目录下
添加opencv所需要的依赖库:
GCC 4.4.x or later

  • List item
  • CMake 2.8.7 or higher
  • 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
  • [compiler] sudo apt-get install build-essential
    [required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
    [optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

    使用CMake构建OpenCV

    cd ~/opencv
    mkdir build
    cd build

    cmake编译(后面的两个点不能丢)

     cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
    

    Unhandled Exception: OpenCvSharp.OpenCvSharpException: Failed to create VideoCapture System.TypeInitializationException: The type initializer for ‘OpenCvSharp.NativeMethods’ threw an exception.
    OpenCvSharp.OpenCvSharpException: Unable to load shared library ‘OpenCvSharpExtern’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libOpenCvSharpExtern: cannot open shared object file: No such file or directory —> System.DllNotFoundException: Unable to load shared library ‘OpenCvSharpExtern’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libOpenCvSharpExtern: cannot open shared object file: No such file or directory

    export LD_LIBRARY_PATH="/lib:/usr/lib:/usr/local/lib"

    环境变量并重新启动系统