如何编译点云库(PCL)带实例(Ubuntu)?

How to compile Point Cloud Library (PCL) with examples (Ubuntu)?

我正在使用 Ubuntu 18.04,但是对于任何最近的 Linux 发行版,这个问题应该几乎相同。

基于此post:

How to install Point Cloud Library v1.8 on Ubuntu 16

我正在尝试从源代码构建 Point Cloud Library,如下所示:

安装各种包:

sudo apt-get -y install g++ cmake cmake-gui doxygen mpi-default-dev openmpi-bin openmpi-common
sudo apt-get -y install libusb-1.0-0-dev libqhull* libusb-dev libgtest-dev
sudo apt-get -y install git-core freeglut3-dev pkg-config build-essential libxmu-dev libxi-dev
sudo apt-get -y install libphonon-dev libphonon-dev phonon-backend-gstreamer
sudo apt-get -y install phonon-backend-vlc graphviz mono-complete
sudo apt-get -y install qt5-default
sudo apt-get -y install libflann-dev

sudo apt-get -y install libflann1.9
sudo apt-get -y install libboost-dev
sudo apt-get -y install libeigen3-dev

编译安装VTK 8.1.1:

cd ~/Downloads
wget http://www.vtk.org/files/release/8.1/VTK-8.1.1.tar.gz
tar -zxvf VTK-8.1.1.tar.gz
cd VTK-8.1.1
mkdir build
cd build
cmake ..
make
sudo make install

编译安装PCL1.8.1

cd ~/Downloads
wget https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.1.tar.gz
tar -zxvf pcl-1.8.1.tar.gz
cd pcl-pcl-1.8.1
mkdir build
cd build
cmake ..
make
sudo make install

运行 一个 ldconfig

sudo ldconfig

效果很好,但是 PCL 示例未设置为默认编译,我真的很希望能够 运行 这些示例。参考这个 post:

Cannot compile pcl examples with cmake

我按照上面的方法进行,只是在去皮后PCL,我打开了文件

~/Downloads/pcl-pcl-1.8.1/CMakeLists.txt

我为 example 按了 Ctrl-F 并找到了以下几行:

### ---[ Set up for examples
#include("${PCL_SOURCE_DIR}/cmake/pcl_examples.cmake")

接下来我删除了这两行第二行开头的注释字符#,所以现在我有:

### ---[ Set up for examples
include("${PCL_SOURCE_DIR}/cmake/pcl_examples.cmake")

继续执行上述步骤,当我执行 cmake .. 现在我得到:

~/Downloads/pcl-pcl-1.8.1/build$ cmake ..
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Using CPU native flags for SSE optimization:  -march=native
-- Performing Test HAVE_MM_MALLOC
-- Performing Test HAVE_MM_MALLOC - Success
-- Performing Test HAVE_POSIX_MEMALIGN
-- Performing Test HAVE_POSIX_MEMALIGN - Success
-- Performing Test HAVE_SSE4_2_EXTENSIONS
-- Performing Test HAVE_SSE4_2_EXTENSIONS - Success
-- Performing Test HAVE_SSE4_1_EXTENSIONS
-- Performing Test HAVE_SSE4_1_EXTENSIONS - Success
-- Performing Test HAVE_SSSE3_EXTENSIONS
-- Performing Test HAVE_SSSE3_EXTENSIONS - Success
-- Performing Test HAVE_SSE3_EXTENSIONS
-- Performing Test HAVE_SSE3_EXTENSIONS - Success
-- Performing Test HAVE_SSE2_EXTENSIONS
-- Performing Test HAVE_SSE2_EXTENSIONS - Success
-- Performing Test HAVE_SSE_EXTENSIONS
-- Performing Test HAVE_SSE_EXTENSIONS - Success
-- -- GCC > 4.3 found, enabling -Wabi
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Found OpenMP
-- Checking for module 'eigen3'
--   Found eigen3, version 3.3.4
-- Found Eigen: /usr/include/eigen3  
-- Eigen found (include: /usr/include/eigen3, version: 3.3.4)
-- Checking for module 'flann>=1.7.0'
--   Found flann, version 1.9.1
-- Found FLANN: /usr/lib/x86_64-linux-gnu/libflann_cpp.so (Required is at least version "1.7.0") 
-- FLANN found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libflann_cpp.so;debug;/usr/lib/x86_64-linux-gnu/libflann_cpp.so)
-- Found LIBUSB_1: /usr/lib/x86_64-linux-gnu/libusb-1.0.so  
-- Checking for module 'libusb-1.0'
--   Found libusb-1.0, version 1.0.21
-- Found USB_10: /usr/lib/x86_64-linux-gnu/libusb-1.0.so  
-- Could NOT find OpenNI (missing: OPENNI_LIBRARY OPENNI_INCLUDE_DIR) 
CMake Warning at cmake/pcl_targets.cmake:864 (message):
  OpenNI grabber support: not building because OpenNI not found
Call Stack (most recent call first):
  CMakeLists.txt:296 (PCL_ADD_GRABBER_DEPENDENCY)


-- Could NOT find OpenNI2 (missing: OPENNI2_LIBRARY OPENNI2_INCLUDE_DIRS) 
CMake Warning at cmake/pcl_targets.cmake:864 (message):
  OpenNI2 grabber support: not building because OpenNI2 not found
Call Stack (most recent call first):
  CMakeLists.txt:297 (PCL_ADD_GRABBER_DEPENDENCY)


-- Could NOT find FZAPI (missing: FZAPI_LIBS FZAPI_INCLUDE_DIRS) 
CMake Warning at cmake/pcl_targets.cmake:864 (message):
  Fotonic camera support: not building because FZAPI not found
Call Stack (most recent call first):
  CMakeLists.txt:298 (PCL_ADD_GRABBER_DEPENDENCY)


-- Could NOT find ensenso (missing: ENSENSO_LIBRARY ENSENSO_INCLUDE_DIR) 
CMake Warning at cmake/pcl_targets.cmake:864 (message):
  IDS-Imaging Ensenso camera support: not building because Ensenso not found
Call Stack (most recent call first):
  CMakeLists.txt:299 (PCL_ADD_GRABBER_DEPENDENCY)


-- Could NOT find davidSDK (missing: DAVIDSDK_LIBRARY DAVIDSDK_INCLUDE_DIR) 
CMake Warning at cmake/pcl_targets.cmake:864 (message):
  David Vision Systems SDK support: not building because davidSDK not found
Call Stack (most recent call first):
  CMakeLists.txt:300 (PCL_ADD_GRABBER_DEPENDENCY)


-- Could NOT find DSSDK (missing: DSSDK_LIBRARIES DSSDK_INCLUDE_DIRS) 
CMake Warning at cmake/pcl_targets.cmake:864 (message):
  DepthSense SDK support: not building because DSSDK not found
Call Stack (most recent call first):
  CMakeLists.txt:301 (PCL_ADD_GRABBER_DEPENDENCY)


-- Could NOT find RSSDK (missing: RSSDK_LIBRARIES RSSDK_INCLUDE_DIRS) 
CMake Warning at cmake/pcl_targets.cmake:864 (message):
  RealSense SDK support: not building because RSSDK not found
Call Stack (most recent call first):
  CMakeLists.txt:302 (PCL_ADD_GRABBER_DEPENDENCY)


-- Checking for module 'metslib'
--   No package 'metslib' found
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version "1.6.34") 
-- Found Qhull: /usr/lib/x86_64-linux-gnu/libqhull.so  
-- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found CUDA Toolkit v9.2
-- CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_53,code=sm_53;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61
-- VTK_MAJOR_VERSION 8, rendering backend: OpenGL2
-- VTK found (include: /usr/local/include/vtk-8.1, lib: vtksys;vtkCommonCore;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonDataModel;vtkCommonColor;vtkCommonExecutionModel;vtkCommonComputationalGeometry;vtkFiltersCore;vtkFiltersGeneral;vtkImagingCore;vtkImagingFourier;vtkalglib;vtkFiltersStatistics;vtkFiltersExtraction;vtkInfovisCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingCore;vtkzlib;vtkfreetype;vtkRenderingFreeType;vtkRenderingContext2D;vtkChartsCore;vtkDICOMParser;vtklz4;vtkIOCore;vtkIOLegacy;vtkexpat;vtkIOXMLParser;vtkDomainsChemistry;vtkglew;vtkRenderingOpenGL2;vtkDomainsChemistryOpenGL2;vtkIOXML;vtkParallelCore;vtkFiltersAMR;vtkFiltersFlowPaths;vtkFiltersGeneric;vtkImagingSources;vtkFiltersHybrid;vtkFiltersHyperTree;vtkImagingGeneral;vtkFiltersImaging;vtkFiltersModeling;vtkFiltersParallel;vtkFiltersParallelImaging;vtkFiltersPoints;vtkFiltersProgrammable;vtkFiltersSMP;vtkFiltersSelection;vtkFiltersTexture;vtkFiltersTopology;verdict;vtkFiltersVerdict;vtkmetaio;vtkjpeg;vtkpng;vtktiff;vtkIOImage;vtkImagingHybrid;vtkInfovisLayout;vtkInteractionStyle;vtkImagingColor;vtkRenderingAnnotation;vtkRenderingVolume;vtkInteractionWidgets;vtkViewsCore;vtkproj4;vtkGeovisCore;vtkhdf5_hl;vtkhdf5;vtkIOAMR;vtkIOEnSight;vtkNetCDF;vtkexoIIc;vtkIOExodus;vtkgl2ps;vtkRenderingGL2PSOpenGL2;vtklibharu;vtkIOExport;vtkIOExportOpenGL2;vtkIOGeometry;vtkIOImport;vtklibxml2;vtkIOInfovis;vtkIOLSDyna;vtkIOMINC;vtkoggtheora;vtkIOMovie;vtknetcdfcpp;vtkIONetCDF;vtkIOPLY;vtkjsoncpp;vtkIOParallel;vtkIOParallelXML;vtksqlite;vtkIOSQL;vtkIOTecplotTable;vtkIOVideo;vtkImagingMath;vtkImagingMorphological;vtkImagingStatistics;vtkImagingStencil;vtkInteractionImage;vtkRenderingContextOpenGL2;vtkRenderingImage;vtkRenderingLOD;vtkRenderingLabel;vtkRenderingVolumeOpenGL2;vtkViewsContext2D;vtkViewsInfovis
-- Could NOT find PCAP (missing: PCAP_LIBRARIES PCAP_INCLUDE_DIRS) 
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   system
--   filesystem
--   thread
--   date_time
--   iostreams
--   chrono
--   atomic
--   regex
CMake Error at CMakeLists.txt:431 (include):
  include could not find load file:

    /home/cdahms/Downloads/pcl-pcl-1.8.1/cmake/pcl_examples.cmake


-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- DOXYGEN_FOUND 
-- HTML_HELP_COMPILER 
-- Found CPack generators: DEB
-- The following subsystems will be built:
--   common
--   octree
--   io
--   kdtree
--   search
--   sample_consensus
--   filters
--   2d
--   geometry
--   features
--   ml
--   segmentation
--   visualization
--   surface
--   registration
--   keypoints
--   tracking
--   recognition
--   stereo
--   outofcore
--   people
--   tools
-- The following subsystems will not be built:
--   apps: No reason
--   examples: Code examples are disabled by default.
--   simulation: Disabled by default.
--   global_tests: No reason
-- Configuring incomplete, errors occurred!

由于 cmake .. 这一步没有成功,所以当我 make 时,我得到:

$ make
make: *** No targets specified and no makefile found.  Stop.

我想除了在 CMakeLists.txt 中取消对 include("${PCL_SOURCE_DIR}/cmake/pcl_examples.cmake") 行的注释外,还必须有其他设置吗?有人可以告知成功编译示例所需的额外步骤吗?

在您的 cmake 命令中,请添加 -DBUILD_examples=ON 作为启用示例的选项。