ubuntu 18.04 安装PCL 1.12.1

写在前面
首先,安装PCL库别装VTK=8.2.0,再下面第一步安装依赖里面sudo apt-get install libvtk7.1-qt libvtk7.1 libvtk7-qt-dev就可以很轻松的安装VTK 7.1版本了,跟着那些装8.2的,搞了半天还装不上,浪费时间。

方法一(这样简单不会出错,但是装的是1.8.1的PCL库):

sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl  
sudo apt-get update  
sudo apt-get install libpcl-dev

1、先去下载pcl源码(因为这个下载比较慢,先下载,同时装依赖,省时间)

git clone https://github.com/PointCloudLibrary/pcl.git 

上面默认的是最新版本的PCL,不一定是1.12.1的

觉得慢的话用下面这个

git clone https://gitee.com/mirrors/pcl.git

如果想用指定版本的PCL,去这里选个自己需要的版本
在这里插入图片描述

下载源码

在这里插入图片描述

2、安装依赖

sudo apt-get update  
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common 
sudo apt-get install libflann1.9 libflann-dev  #这里改成1.9
sudo apt-get install libeigen3-dev 
sudo apt-get install libboost-all-dev
sudo apt-get install libvtk7.1-qt libvtk7.1 libvtk7-qt-dev
sudo apt-get install libqhull* libgtest-dev
sudo apt-get install freeglut3-dev pkg-config
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install mono-complete
sudo apt-get install openjdk-8-jdk openjdk-8-jre

中间提示选择Y/N的全部选Y

可视化依赖库:

安装OpenNI,OpenNI2

sudo apt-get install libopenni-dev 
sudo apt-get install libopenni2-dev

安装QT5:

sudo apt install qtcreator
sudo apt install qt5-default

安装metslib

wget https://www.coin-or.org/download/source/metslib/metslib-0.5.3.tgz
tar xzvf metslib-0.5.3.tgz
cd metslib-0.5.3
./configure
make -j`nproc`
sudo make install

安装ensensor

sudo dpkg -i ensenso-sdk-3.3.1385-x64.deb
sudo dpkg -i codemeter_7.40.5001.502_amd64.deb
sudo apt-get -f install

在这里插入图片描述

上面两个的下载地址分别是:
1、https://www.ensenso.com/support/sdk-download/
在这里插入图片描述

2、https://www.wibu.com/support/user/downloads-user-software.html
在这里插入图片描述
在这里插入图片描述

3、PCL源码下载完后,进行编译

cd pcl-pcl-1.12.1
# 切换到指定版本v1.12.1再编译
git checkout pcl-1.12.1
# 创建目录并进入目录
mkdir build && cd build

#安装在系统目录
cmake -DCMAKE_BUILD_TYPE=None \
      -DCMAKE_INSTALL_PREFIX=/usr/local \
      -DBUILD_GPU=ON \
      -DBUILD_apps=ON \
      -DBUILD_simulation=ON \
      -DBUILD_examples=ON ..
#也可以安装在自己指定的目录,如下所示(主要是改下安装空间):
cmake -DCMAKE_BUILD_TYPE=None \
      -DCMAKE_INSTALL_PREFIX=~/softwares/lib/pcl1121 \
      -DBUILD_GPU=ON \
      -DBUILD_apps=ON \
      -DBUILD_simulation=ON \
      -DBUILD_examples=ON ..

# Orin 切换到 MAXN POWER MODE
# 进行编译
make -j8

#编译完后,执行安装
sudo make install

成功后界面如下(希望你能直接得到这个画面):

在这里插入图片描述

cmake 的时候,会报一些CLOUD NOT find XXX之类的,虽然不影响cmake成功,但可能后续会对make造成影响,所以最好能解决掉。
其中我这里有:

Could NOT find Pcap

解决办法:http://t.zoukankan.com/nanmi-p-12840793.html
在这也贴上我的cmake界面吧(虽然还有一些CLOUD NOT find XXX之类的,但最终make成功了,如果你也是这些,那就不用管了):

-- Could NOT find ClangFormat (missing: ClangFormat_EXECUTABLE ClangFormat_VERSION) (Required is at least version "10")
-- Using CPU native flags for SSE optimization: -msse4.2 -mfpmath=sse -march=native
-- Found OpenMP, spec date 201511
-- Eigen found (include: /usr/include/eigen3, version: 3.3.4)
-- FLANN found (include: /usr/include, lib: /usr/lib/x86_64-linux-gnu/libflann_cpp.so)
-- OpenNI found (version: 1.5.4.0, include: /usr/include/ni, lib: /usr/lib/libOpenNI.so;libusb::libusb)
-- OpenNI2 found (version: 2.2.0.33, include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so;libusb::libusb)
-- QHULL found (include: /usr/include, lib: /usr/lib/x86_64-linux-gnu/libqhull_r.so)
-- Found CUDA Toolkit v11.1
-- CMAKE_CUDA_ARCHITECTURES: 35;37;50;52;53;60;61;62;70;72;75;80;86
-- The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
but not all the files it references.

-- The imported target "pvtk" references the file
   "/usr/bin/pvtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
but not all the files it references.

-- VTK version: 7.1.1
-- VTK rendering backend: OpenGL2
-- VTK Qt support: YES
-- VTK include: /usr/include/vtk-7.1;/usr/include/freetype2;/usr/include;/usr/include/x86_64-linux-gnu;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include;/usr/lib/x86_64-linux-gnu/openmpi/include;/usr/include/python3.6m;/usr/include/hdf5/openmpi;/usr/include/jsoncpp;/usr/include/libxml2;/usr/include/tcl
-- VTK libs: vtkChartsCore;vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonExecutionModel;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersCore;vtkInfovisCore;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;/usr/lib/x86_64-linux-gnu/libz.so;vtkDICOMParser;vtkDomainsChemistry;vtkIOLegacy;vtkIOCore;vtkIOXMLParser;/usr/lib/x86_64-linux-gnu/libexpat.so;vtkDomainsChemistryOpenGL2;vtkRenderingOpenGL2;vtkIOImage;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkFiltersAMR;vtkIOXML;vtkParallelCore;vtkFiltersFlowPaths;vtkFiltersGeneric;vtkFiltersHybrid;vtkImagingSources;vtkFiltersHyperTree;vtkFiltersImaging;vtkImagingGeneral;vtkFiltersModeling;vtkFiltersParallel;vtkFiltersParallelDIY2;vtkParallelMPI;vtkFiltersParallelFlowPaths;vtkFiltersParallelGeometry;vtkFiltersParallelImaging;vtkFiltersParallelMPI;vtkFiltersParallelStatistics;vtkFiltersPoints;vtkFiltersProgrammable;vtkFiltersPython;/usr/lib/x86_64-linux-gnu/libpython3.6m.so;vtkWrappingPythonCore;vtkWrappingTools;vtkFiltersReebGraph;vtkFiltersSMP;vtkFiltersSelection;vtkFiltersTexture;vtkFiltersVerdict;verdict;vtkGUISupportQt;vtkInteractionStyle;vtkGUISupportQtOpenGL;vtkGUISupportQtSQL;vtkIOSQL;sqlite3;vtkGUISupportQtWebkit;vtkViewsCore;vtkInteractionWidgets;vtkImagingColor;vtkImagingHybrid;vtkRenderingAnnotation;vtkRenderingVolume;vtkViewsQt;vtkViewsInfovis;vtkInfovisLayout;vtkRenderingLabel;vtkGeovisCore;/usr/lib/x86_64-linux-gnu/libproj.so;vtkIOAMR;/usr/lib/x86_64-linux-gnu/hdf5/openmpi/libhdf5.so;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so;/usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so;/usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so;/usr/lib/x86_64-linux-gnu/hdf5/openmpi/libhdf5_hl.so;vtkIOEnSight;vtkIOExodus;vtkexoIIc;/usr/lib/x86_64-linux-gnu/libnetcdf_c++.so;/usr/lib/x86_64-linux-gnu/libnetcdf.so;vtkIOExport;vtkRenderingGL2PSOpenGL2;/usr/lib/x86_64-linux-gnu/libgl2ps.so;vtkIOFFMPEG;vtkIOMovie;/usr/lib/x86_64-linux-gnu/libtheoraenc.so;/usr/lib/x86_64-linux-gnu/libtheoradec.so;/usr/lib/x86_64-linux-gnu/libogg.so;vtkIOGDAL;vtkIOGeoJSON;/usr/lib/x86_64-linux-gnu/libjsoncpp.so;vtkIOGeometry;vtkIOImport;vtkIOInfovis;/usr/lib/x86_64-linux-gnu/libxml2.so;vtkIOLSDyna;vtkIOMINC;vtkIOMPIImage;vtkIOMPIParallel;vtkIOParallel;vtkIONetCDF;vtkIOMySQL;vtkIOODBC;vtkIOPLY;vtkIOParallelExodus;vtkIOParallelLSDyna;vtkIOParallelNetCDF;vtkIOParallelXML;vtkIOPostgreSQL;vtkIOTecplotTable;vtkIOVPIC;VPIC;vtkIOVideo;vtkIOXdmf2;vtkxdmf2;vtkImagingMath;vtkImagingMorphological;vtkImagingStatistics;vtkImagingStencil;vtkInfovisBoostGraphAlgorithms;vtkInteractionImage;vtkLocalExample;vtkParallelMPI4Py;vtkPythonInterpreter;vtkRenderingContextOpenGL2;vtkRenderingExternal;vtkRenderingFreeTypeFontConfig;vtkRenderingImage;vtkRenderingLICOpenGL2;vtkRenderingLOD;vtkRenderingMatplotlib;vtkRenderingParallel;vtkRenderingParallelLIC;vtkRenderingQt;vtkRenderingSceneGraph;vtkRenderingVolumeAMR;vtkRenderingVolumeOpenGL2;vtkTestingGenericBridge;vtkTestingIOSQL;vtkTestingRendering;vtkViewsContext2D;vtkViewsGeovis;vtkWrappingJava
-- Qt version: 5.9.5
-- Found Pcap: /usr/local/lib/libpcap.so  
-- Found Boost: /usr/include (found suitable version "1.65.1", minimum required is "1.65.0") found components: filesystem date_time iostreams system regex 
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Found GLEW: /usr/include  
-- DOXYGEN_FOUND 
-- HTML_HELP_COMPILER 
-- Found CPack generators: DEB
-- PCL build with following flags:
--  -Wabi=11 -Wall -Wextra -Wno-unknown-pragmas -fno-strict-aliasing -Wno-format-extra-args -Wno-sign-compare -Wno-invalid-offsetof -Wno-conversion -msse4.2 -mfpmath=sse -march=native -mavx2 -fopenmp 
-- The following subsystems will be built:
--   common
--   kdtree
--   octree
--   search
--   sample_consensus
--   filters
--   2d
--   geometry
--   io
--   features
--   ml
--   segmentation
--   visualization
--   surface
--   registration
--   keypoints
--   tracking
--   recognition
--   stereo
--   outofcore
--   examples
--   people
--   tools
-- The following subsystems will not be built:
--   apps: Disabled by default
--   benchmarks: Disabled by default
--   simulation: Disabled by default.
--   global_tests: Disabled by default
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/Downloads/pcl-pcl-1.12.1/build

4、测试PCL是否安装成功
打开终端,找个.pcd 点云文件可视化下

在这里插入图片描述

或者是编译以下,测试下:

创建文件test_pcl.cpp,把下面代码复制进去,保存退出:

#include <iostream>
#include <pcl/common/common_headers.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/console/parse.h>
 
int main(int argc, char **argv) {
    
    
  std::cout << "Test PCL !" << std::endl;
  pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr (new pcl::PointCloud<pcl::PointXYZRGB>);
  uint8_t r(255), g(15), b(15);
  for (float z(-1.0); z <= 1.0; z += 0.05) {
    
    
  	for (float angle(0.0); angle <= 360.0; angle += 5.0) {
    
    
      pcl::PointXYZRGB point;
      point.x = 0.5 * cosf (pcl::deg2rad(angle));
      point.y = sinf (pcl::deg2rad(angle));
      point.z = z;
      uint32_t rgb = (static_cast<uint32_t>(r) << 16 | static_cast<uint32_t>(g) << 8 | static_cast<uint32_t>(b));
      point.rgb = *reinterpret_cast<float*>(&rgb);
      point_cloud_ptr->points.push_back (point);
    }
    if (z < 0.0) {
    
    
      r -= 12;
      g += 12;
    }
    else {
    
    
      g -= 12;
      b += 12;
    }
  }
  
  point_cloud_ptr->width = (int) point_cloud_ptr->points.size ();
  point_cloud_ptr->height = 1;
 
  pcl::visualization::CloudViewer viewer ("test");
  viewer.showCloud(point_cloud_ptr);
  while (!viewer.wasStopped()){
    
     };
  return 0;
}

创建文件CMakeLists.txt ,将下面内容复制到进去,保存退出

cmake_minimum_required(VERSION 2.6)
project(test_pcl)
 
find_package(PCL 1.2 REQUIRED)
 
include_directories(${
    
    PCL_INCLUDE_DIRS})
link_directories(${
    
    PCL_LIBRARY_DIRS})
add_definitions(${
    
    PCL_DEFINITIONS})
 
add_executable(test_pcl test_pcl.cpp)
 
target_link_libraries (test_pcl ${
    
    PCL_LIBRARIES})
 
install(TARGETS test_pcl RUNTIME DESTINATION bin)

如下:

在这里插入图片描述
然后在这里打开终端输入:

mkdir build && cd build
cmake ..
make
./test_pcl

如下,表示安装成功:

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/jin15203846657/article/details/125978509