當(dāng)前位置:首頁 > IT技術(shù) > 系統(tǒng)服務(wù) > 正文

Ubuntu16.04的Opencv源碼安裝3.2.0 和 3.0.0-alpha詳細(xì)安裝教程
2022-04-19 11:06:47


教程1: Opencv3.0.0-alpha在ubuntu16.04的安裝

# step 1 
# 安裝依賴 (太多了,自己相應(yīng)替換)
sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-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

sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-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 --fix-missing


# step 2
# 下載解包
wget https://github.com/Itseez/opencv/archive/3.0.0-alpha.zip
unzip opencv-3.0.0-alpha.zip
# step 3
# 編譯
cd 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 BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
# step 4
#安裝
make
sudo make install

# step 5
# 安裝完成,進(jìn)行整理
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
sudo apt-get update

教程2:

今天重裝了Opencv3.20 和Opencv3.2.0conbtrib,將安裝日志記錄如下:

1. 查詢自己的Opencv版本 ??pkg-config --modversion opencv??

2. 下載??Opencv3.2.0 和Opencv contrib3.2.0?? 對于opencv3.2.0 ???https://pan.baidu.com/s/1bp03gab??? 對于Opencv3.2.0 contrib

3. 卸載當(dāng)前的Opencv ,進(jìn)入安裝的build目錄,執(zhí)行 ??sudo make uninstall?? ,然后??cd ..?? 執(zhí)行??rm -rf build??

4. 清理/usr中所有的opencv相關(guān)選項(xiàng) ??rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*??

5. 執(zhí)行 ??sudo make -j16?? 和 ??sudo make install?? , 在make的時候我遇到一個問題就是??fatal error: LAPACKE_H_PATH-NOTFOUND/lapacke.h??: ??No such file or directory #include “LAPACKE_H_PATH-NOTFOUND/lapacke.h??” 原因:未找到lapacke.h文件 ,只需要??sudo apt-get install liblapacke-dev checkinstall??就可以解決繼續(xù)make了。成功后進(jìn)行第5步。

6. ??cd /usr??

7. ??find . -name "*opencv*" | xargs sudo rm -rf??

8. 成功后在終端中打開 /etc/ld.conf.d/opencv.conf 文件,并在最后一行添加 /usr/local/lib,如果沒有這個文件那就新建一個。然后打開 /etc/bash.bashrc 文件,在最后一行中添加

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv320/lib/pkgconfig
export PKG_CONFIG_PATH

最后. ??sudo ldconfig??生效

備注:最后使用??pkg-config --modversion opencv??查詢版本如果報錯為:

Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found

則需要運(yùn)行下邊語句:

sudo cp /usr/local/opencv320/lib/pkgconfig/opencv.pc /usr/lib/pkgconfig


本文摘自 :https://blog.51cto.com/u

開通會員,享受整站包年服務(wù)立即開通 >