系统相关
首页 > 系统相关> > ubuntu18.04 安装opencv3.4、PCL、VTK教程

ubuntu18.04 安装opencv3.4、PCL、VTK教程

作者:互联网

先下载好opencv3.4.1+VTK7.1+PCL1.8.1安装包。
一定要依次执行下面安装命令

一、安装opencv:

1、解压opencv进入解压后目录文件夹,打开终端:

mkdir build
cd build

或 自行创建build文件夹

2、安装依赖库

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

3、继续安装依赖

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

4、cmake一下

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" ..

5、执行命令,漫长的编译过程

make

若使用“make -j CPU核心数”进行编译,当CPU核心数较大时,编译时可能会导致内存爆满,导致编译出错,此时,只需减少编译时使用的CPU核心数即可。

6、安装

sudo make install

7、sudo make install 执行完毕后OpenCV编译过程就结束了,接下来就需要配置一些OpenCV的编译环境首先将OpenCV的库添加到路径,从而可以让系统找到

sudo gedit /etc/ld.so.conf.d/opencv.conf

执行此命令后打开的可能是一个空白的文件,不用管,只需要在文件末尾添加

/usr/local/lib 

8、执行如下命令使得刚才的配置路径生效

sudo ldconfig

9、配置bash

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*

2、安装VTK7.1步骤:

解压安装包进去解压文件夹打开终端

mkdir build

cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE ..

make

sudo make install

安装完成

3、安装PCL步骤:

解压安装包进去解压文件夹打开终端

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=None ..
make
sudo make install

标签:install,get,VTK,sudo,apt,dev,PCL,opencv3.4,usr
来源: https://blog.csdn.net/LuckyKing01/article/details/122260760