先下载好opencv3.4.1+VTK7.1+PCL1.8.1安装包。
一定要依次执行下面安装命令
mkdir build cd build
或 自行创建build文件夹
sudo apt-get update sudo apt-get install cmake
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev
问题1**********************
近期需要在ubuntu18.04系统上安装opencv但是在安装依赖包的过程中,有一个依赖包,libjasper-dev在使用命令
sudo apt-get install libjaster-dev
提示:errorE: unable to locate libjasper-dev
后来google到解决办法,复制到这里
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" sudo apt update sudo apt install libjasper1 libjasper-dev
成功的解决了问题,其中libjasper1是libjasper-dev的依赖包
再次执行:
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev
sudo apt-get install pkg-config
sudo apt-get install -y autoconf automake build-essential git libass-dev libfreetype6-dev libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev
sudo apt-get install libavformat-dev libavcodec-dev libswresample-dev libswscale-dev libavutil-dev libsdl1.2-dev
ffmpeg安装:
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next sudo apt-get update sudo apt-get install ffmpeg
卸载:sudo apt-get purge ffmpeg
安装各种依赖
sudo apt-get update
sudo apt-get install git build-essential linux-libc-dev cmake cmake-gui libusb-1.0-0-dev libusb-dev libudev-dev mpi-default-dev openmpi-bin openmpi-common libflann1.9 libflann-dev libeigen3-dev libboost-all-dev libcanberra-gtk-module
其他依赖
sudo apt-get install libqhull* libgtest-dev freeglut3-dev pkg-config libxmu-dev libxi-dev mono-complete libopenni-dev libopenni2-dev
源码安装vtk库(很重要!!!apt安装的方式会出现.so文件缺失的情况!)
首先安装依赖项X11,OpenGL
sudo apt-get install libx11-dev libxext-dev libxtst-dev libxrender-dev libxmu-dev libxmuu-dev
sudo apt-get install build-essential libgl1-mesa-dev libglu1-mesa-dev
cmake -D CMAKE_BUILD_TYPE=RELEASE WITH_CUDA=OFF ..
或
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_FFMPEG=ON -D WITH_TBB=ON -D WITH_GTK=ON -D WITH_V4L=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -DWITH_QT=OFF -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..
make
若使用“make -j CPU核心数”进行编译,当CPU核心数较大时,编译时可能会导致内存爆满,导致编译出错,此时,只需减少编译时使用的CPU核心数即可。
sudo make install
sudo gedit /etc/ld.so.conf.d/opencv.conf
执行此命令后打开的可能是一个空白的文件,不用管,只需要在文件末尾添加
/usr/local/lib
sudo ldconfig
sudo gedit /etc/bash.bashrc
在最末尾添加
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH
保存,执行如下命令使得配置生效
source /etc/bash.bashrc
更新
sudo apt-get install mlocate sudo updatedb
至此所有的配置都已经完成
删除opencv
sudo 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*
解压安装包进去解压文件夹打开终端
mkdir build cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE .. make sudo make install
安装完成
解压安装包进去解压文件夹打开终端
mkdir build cd build
cmake -DCMAKE_BUILD_TYPE=None .. make sudo make install