ubuntu16.04安裝OpenCV3.0.0
阿新 • • 發佈:2019-02-18
OpenCV安裝了好多遍,最重要的是要網好,中間幾次出錯,都是網路狀態不好,下載的東西下載不完全。
Step 1. 安裝依賴項
sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python3-dev python3-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
mkdir opencv
cd opencv
將下載好的檔案複製到根目錄下剛建立的opencv資料夾中,解壓檔案。
Step 3.安裝OpenCV
進入opencv→opencv-3.0.0-alpha,開啟終端執行
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j $(nproc)
sudo make install
Step 4. 完成安裝
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
Step 5. 測試
cd opencv/opencv-3.0.0-alpha/samples/
sudo cmake .
sudo make -j $(nproc)
cd cpp/
./cpp-example-facedetect lena.jpg // \(../data/lena.jpg\) OpenCV 3.0 beta
./cpp-example-houghlines pic1.png // \(../data/pic1.jpg\) OpenCV 3.0 beta
出現圖片即為安裝成功!