【OpenCV】在Ubuntu下佈署OpenCV

安裝相關套件:
下指令(要一些時間)
 $ sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394–22-dev libavcodec-dev libavformat-dev libswscale-dev

  1. 下載OpenCV:
    官網(http://opencv.org/) 即可下載,本次使用2.4.11。
  2. 解壓縮:
    移到檔案所在位置,下指令
    $ tar -xvf opencv-2.4.6.1.tar.gz
    然後會出現opencv-2.4.11資料夾
  3. cmake:
    下指令
    $ cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
  4. make:
    下指令(要一些時間)
    $ make
  5. 安裝:
    下指令
    $ sudo make install
  6. 修改設定檔
    $ sudo vim /etc/ld.so.conf.d/opencv.conf
    會打開一個檔案,把下面這行加上去,然後按「:wq」儲存離開
     /usr/local/lib
  7. 執行設定檔
    $sudo ldconfig
  8. 設定環境變數
    $ sudo vim /etc/bash.bashrc
    把這些加到最後面
    PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
    export PKG_CONFIG_PATH
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.