PCL学习(1)PCL初玩

PCL学习

前言

  最近进行毕设论文的设计时,博主学习计算机相关学习的过程中,但是浏览中感觉PCL进行点云可视化十分强大,而且除此之外,对于本身研究方向的扩展的SLAM中,MRPT的显示也是很用科技感觉。

  对于这两个的学习,想要加入自己的学习历程。但是苦于快要毕业,这部分的地方可能不能特别深入,只能一步步抽点时间时间,打算先学pcl点云库的操作再来看看还有时间学习MRPT么。

  但是相比MRPT更新速度慢,而且我在ubuntu16.04的环境下,它的github代码,报错导致我没有进行研究下去的兴趣,最后只能简单的安装它的稳定版本1.50。而pcl点云库强大,在ubuntu16.04倒是安装成功了,算是十分容易,我安装的版本当时github上是1.81版本,现在github版本已经是1.9了,可以说更新实在是蛮快了。

  pcl很容易查看版本信息,因为你从github下载后,阅读它的README.md文件就能显示出来。


安装

  其实安装无非就是几行代码的事。有些人可能想要知道,哪些是必须的依赖。

  可以查看官网的文档的依赖项。我截图一下:

  从这里看出来,必要的用四个,后面三个都是可选的。安装上面的提示安装后,安装一般的步骤也就是创建build文件夹,然后cmake,然后make,然后make install。

  实在觉得懒的话,可以参看这篇文章。不过我自己编译的话,是按照官网指示的必备依赖项,比如boost,eigen等等,这些基础环境在我实践和进行其他类型的项目就早已安装上了,所以我就偷懒,让各位阅读别人的安装教程,如果确实需要我编写个安装的,我会另外开博文,当然你得下面评论说你需要。


说明

  这一节部分,会讲述PCL做什么,老生长谈的话题。这里从官方github摘录一段文字:

  The Point Cloud Library (PCL) is a standalone, large scale, open project for 2D/3D image and point cloud processing.

  这意思是,Point Cloud Library(PCL)是一个独立的大型开放项目,用于2D / 3D图像和点云处理。

  我觉得说得也太系统化了,我都可以夸大一下,补充一下:

  PCL是开发的点云处理库,包含了许多先进算法,包括了滤波、特征提取、曲面重建、分割和模型拟合等。

  来来来,给几个例子

  我选取了几个感觉我最感兴趣的部分。

  不过说这么多,大多数人用的都是显示3D点云。一般项目中尤其是使用RGB-D相机的人,对于深度已经知道了,创建点云文件就很容易了。然后运行这么一行代码就能把自己点云文件展示出来:

pcl_viewer output.pcd

  3D点云库PCL还是很成功的,它在ICRA上出了名,这是当时的论文 3D is here: Point Cloud Library (PCL) ,请感受大牛的味道。

  我还是喜欢比较喜欢这个图标的,刚开始听到的时候,还以为和云计算有关,后面才发现,原来这个东西里面的云和人家八竿子打不着。

  扯了这么多,应该进入正轨了。

一步步引导做例子

关于CMakeLists.txt

  好了,说了这么多,还是没搞定pcl,没事,前面都是虚的,我们来点实际的。

  我们一般使用做项目,比较喜欢cmake,我以前喜欢Windows下的VS2013编写C++代码,不过现在我喜欢linux了,VS2013虽然强大,但是耐不住人家开源的库最喜欢在linux下。在Windows上我最多用来编写一点点简单的例子和编写java项目。

  一般来说,我们的CMAKE的文件肯定用这么几句话,我得说明一下,我用的是3.5.1版本的Cmake。

cmake_minimum_required(VERSION 3.5)# 指明你的项目的cmake最低版本,cmake的高版本目前没有这个,一般不允许运行。
project(example_one)# 指明项目名字

set(CMAKE_CXX_STANDARD 11)# 设置你的c++11

add_executable(example_one main.cpp)# 设置运行程序
# 一般是:add_executable(程序名 源代码文件)

  然后我们要加入pcl点云库的库和链接起来。

  在里面添加这一行代码:

find_package(PCL 1.8 REQUIRED COMPONENTS common io)

  这样之后,我们的CMAKE文件就变成了这样。

cmake_minimum_required(VERSION 3.5)
project(example_one)
# 找到cmake库
find_package(PCL 1.8 REQUIRED COMPONENTS common io)

set(CMAKE_CXX_STANDARD 11)
add_executable(example_one main.cpp)

  我们运行cmake的命令,发现输出就是这样的,没有报错就ok。说明加入的没问题。但是你会发现这太长了吧,我不是都安装了很多东西了么。待会我告诉大家怎么处理,你可以略过,或者稍微看看。

/usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /home/tqw/Documents/studyAtLab/pcl/example_one
-- Checking for module 'eigen3'
--   Found eigen3, version 3.2.92
-- Found Eigen: /usr/include/eigen3  
-- Eigen found (include: /usr/include/eigen3, version: 3.2.92)
-- 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  
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   thread
--   date_time
--   iostreams
--   serialization
--   chrono
--   atomic
--   regex
-- Checking for module 'libusb-1.0'
--   Found libusb-1.0, version 1.0.20
-- Found USB_10: /usr/lib/x86_64-linux-gnu/libusb-1.0.so  
-- Found OpenNI: /usr/lib/libOpenNI.so  
-- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so)
-- Found OpenNI2: /usr/lib/libOpenNI2.so  
-- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so)
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- The imported target "vtkWrapTcl" references the file
   "/usr/bin/vtkWrapTcl"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkWrapTclInit" references the file
   "/usr/bin/vtkWrapTclInit"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkWrapPython" references the file
   "/usr/bin/vtkWrapPython"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkWrapPythonInit" references the file
   "/usr/bin/vtkWrapPythonInit"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkParseJava" references the file
   "/usr/bin/vtkParseJava"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkWrapJava" references the file
   "/usr/bin/vtkWrapJava"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkCommonTCL" references the file
   "/usr/lib/libvtkCommonTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkCommonPythonD" references the file
   "/usr/lib/libvtkCommonPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkCommonJava" references the file
   "/usr/lib/jni/libvtkCommonJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkFilteringTCL" references the file
   "/usr/lib/libvtkFilteringTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkFilteringPythonD" references the file
   "/usr/lib/libvtkFilteringPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkFilteringJava" references the file
   "/usr/lib/jni/libvtkFilteringJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkImagingTCL" references the file
   "/usr/lib/libvtkImagingTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkImagingPythonD" references the file
   "/usr/lib/libvtkImagingPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkImagingJava" references the file
   "/usr/lib/jni/libvtkImagingJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkGraphicsTCL" references the file
   "/usr/lib/libvtkGraphicsTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkGraphicsPythonD" references the file
   "/usr/lib/libvtkGraphicsPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkGraphicsJava" references the file
   "/usr/lib/jni/libvtkGraphicsJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkGenericFilteringTCL" references the file
   "/usr/lib/libvtkGenericFilteringTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkGenericFilteringPythonD" references the file
   "/usr/lib/libvtkGenericFilteringPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkGenericFilteringJava" references the file
   "/usr/lib/jni/libvtkGenericFilteringJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkIOTCL" references the file
   "/usr/lib/libvtkIOTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkIOPythonD" references the file
   "/usr/lib/libvtkIOPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkIOJava" references the file
   "/usr/lib/jni/libvtkIOJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkRenderingTCL" references the file
   "/usr/lib/libvtkRenderingTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkRenderingPythonD" references the file
   "/usr/lib/libvtkRenderingPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkRenderingJava" references the file
   "/usr/lib/jni/libvtkRenderingJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/libvtkRenderingPythonTkWidgets.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkVolumeRenderingTCL" references the file
   "/usr/lib/libvtkVolumeRenderingTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkVolumeRenderingPythonD" references the file
   "/usr/lib/libvtkVolumeRenderingPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkVolumeRenderingJava" references the file
   "/usr/lib/jni/libvtkVolumeRenderingJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkHybridTCL" references the file
   "/usr/lib/libvtkHybridTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkHybridPythonD" references the file
   "/usr/lib/libvtkHybridPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkHybridJava" references the file
   "/usr/lib/jni/libvtkHybridJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkWidgetsTCL" references the file
   "/usr/lib/libvtkWidgetsTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkWidgetsPythonD" references the file
   "/usr/lib/libvtkWidgetsPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkWidgetsJava" references the file
   "/usr/lib/jni/libvtkWidgetsJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkParallelTCL" references the file
   "/usr/lib/libvtkParallelTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkParallelPythonD" references the file
   "/usr/lib/libvtkParallelPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkParallelJava" references the file
   "/usr/lib/jni/libvtkParallelJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkInfovisTCL" references the file
   "/usr/lib/libvtkInfovisTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkInfovisPythonD" references the file
   "/usr/lib/libvtkInfovisPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkInfovisJava" references the file
   "/usr/lib/jni/libvtkInfovisJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkGeovisTCL" references the file
   "/usr/lib/libvtkGeovisTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkGeovisPythonD" references the file
   "/usr/lib/libvtkGeovisPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkGeovisJava" references the file
   "/usr/lib/jni/libvtkGeovisJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkViewsTCL" references the file
   "/usr/lib/libvtkViewsTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkViewsPythonD" references the file
   "/usr/lib/libvtkViewsPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkViewsJava" references the file
   "/usr/lib/jni/libvtkViewsJava.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkChartsTCL" references the file
   "/usr/lib/libvtkChartsTCL.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkChartsPythonD" references the file
   "/usr/lib/libvtkChartsPythonD.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkChartsJava" references the file
   "/usr/lib/jni/libvtkChartsJava.so.5.10.1"
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/vtk-5.10/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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkPythonCore" references the file
   "/usr/lib/libvtkPythonCore.so.5.10.1"
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/vtk-5.10/VTKTargets.cmake"
but not all the files it references.

-- Found libusb-1.0: /usr/include  
** WARNING ** io features related to libusb-1.0 will be disabled
-- looking for PCL_COMMON
-- Found PCL_COMMON: /usr/local/lib/libpcl_common.so  
-- looking for PCL_OCTREE
-- Found PCL_OCTREE: /usr/local/lib/libpcl_octree.so  
-- looking for PCL_IO
-- Found PCL_IO: /usr/local/lib/libpcl_io.so  
-- Found PCL: /usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_thread.so;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_serialization.so;/usr/lib/x86_64-linux-gnu/libboost_chrono.so;/usr/lib/x86_64-linux-gnu/libboost_atomic.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;/usr/lib/x86_64-linux-gnu/libpthread.so;optimized;/usr/local/lib/libpcl_common.so;debug;/usr/local/lib/libpcl_common.so;optimized;/usr/local/lib/libpcl_octree.so;debug;/usr/local/lib/libpcl_octree.so;/usr/lib/libOpenNI.so;/usr/lib/libOpenNI2.so;vtkCommon;vtkFiltering;vtkImaging;vtkGraphics;vtkGenericFiltering;vtkIO;vtkRendering;vtkVolumeRendering;vtkHybrid;vtkWidgets;vtkParallel;vtkInfovis;vtkGeovis;vtkViews;vtkCharts;optimized;/usr/local/lib/libpcl_io.so;debug;/usr/local/lib/libpcl_io.so;/usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_thread.so;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_serialization.so;/usr/lib/x86_64-linux-gnu/libboost_chrono.so;/usr/lib/x86_64-linux-gnu/libboost_atomic.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/libOpenNI.so;/usr/lib/libOpenNI2.so;vtkCommon;vtkFiltering;vtkImaging;vtkGraphics;vtkGenericFiltering;vtkIO;vtkRendering;vtkVolumeRendering;vtkHybrid;vtkWidgets;vtkParallel;vtkInfovis;vtkGeovis;vtkViews;vtkCharts (Required is at least version "1.8") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tqw/Documents/studyAtLab/pcl/example_one/cmake-build-debug

[Finished]

  咦,你有没有发现,从输出信息看见我的什么没安装?

-- The imported target "vtkWrapPython" references the file

   "/usr/bin/vtkWrapPython"

but this file does not exist. 

  哦,没有python的。

-- The imported target "vtkParseJava" references the file

   "/usr/bin/vtkParseJava"

but this file does not exist.

  哦,还没有java的。

  那就安装吧。

 sudo apt-get install libvtk-java
 sudo apt-get install python-vtk

  这时候再Cmake,输出就清晰多了,没那么多烦人的输出了。

/usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /home/tqw/Documents/studyAtLab/pcl/example_one
-- Eigen found (include: /usr/include/eigen3, version: 3.2.92)
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   thread
--   date_time
--   iostreams
--   serialization
--   chrono
--   atomic
--   regex
-- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so)
-- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so)
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
** WARNING ** io features related to libusb-1.0 will be disabled
-- looking for PCL_COMMON
-- looking for PCL_OCTREE
-- looking for PCL_IO
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tqw/Documents/studyAtLab/pcl/example_one/cmake-build-debug

[Finished]

  一些警告无关大雅,需要的时候,我们再修好它。

  现在我们已经找到了pcl库了,但是没有引入库目录文件和将它与运行链接起来

cmake_minimum_required(VERSION 3.5)
project(example_one)



find_package(PCL 1.8 REQUIRED COMPONENTS common io)
# 要使用pcl库需要引入的
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

set(CMAKE_CXX_STANDARD 11)

add_executable(example_one main.cpp)
target_link_libraries(example_one ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})# 链接

  好了,这就是配置了,cmake我们配置好了。

具体实践

官网的例子
#include <iostream>
#include <pcl/io/pcd_io.h>

int
  main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ> cloud;

  // Fill in the cloud data
  cloud.width    = 5;
  cloud.height   = 1;
  cloud.is_dense = false;
  cloud.points.resize (cloud.width * cloud.height);

  for (size_t i = 0; i < cloud.points.size (); ++i)
  {
    cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
  }

  pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
  std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;

  for (size_t i = 0; i < cloud.points.size (); ++i)
    std::cerr << "    " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;

  return (0);
}

  我将之复制到我的main.cpp中,然后运行输出如下:

/home/tqw/Documents/studyAtLab/pcl/example_one/cmake-build-debug/example_one
Saved 5 data points to test_pcd.pcd.
    0.352222 -0.151883 -0.106395
    -0.397406 -0.473106 0.292602
    -0.731898 0.667105 0.441304
    -0.734766 0.854581 -0.0361733
    -0.4607 -0.277468 -0.916762

Process finished with exit code 0

  然后你会看见你生成了这么个东西,test_pcd.pcd。

  然后我们用这个命令查看pcd里有什么?

pcl_viewer test_pcd.pcd 

  你可以看见命令行输出了这么点东西:

The viewer window provides interactive commands; for help, press 'h' or 'H' from within the window.
> Loading test_pcd.pcd [done, 871 ms : 5 points]
Available dimensions: x y z

  老实说,这么稀疏的点,我真的要辨别5个点很难啊。

  看见上面的5个白点了。没错。这个程序就是写了五个点入了点云文件。

解释

  首先,要包含的第一个pcl头文件是 #include <pcl/io/pcd_io.h>。这个头文件的工作是,包含PCD I/O操作定义。由于cmake编译后,已经链接了pcl库,我省略官网的这个头文件 #include <pcl/point_types.h>,这个头文件定义了pcl里的类型,包含几个点类型结构的定义,比如pcl :: PointXYZ。如果你们运行不成功,就加入。

  接下来描述了我们将创建的模板Point Cloud结构。 每个点的类型设置为pcl :: PointXYZ,这是一个具有x,y和z字段的结构。

pcl::PointCloud<pcl::PointXYZ> cloud;

  用随机点值填充PointCloud结构,并设置适当的参数(width,height,is_dense)。

    cloud.width    = 5;
    cloud.height   = 1;
    cloud.is_dense = false;
    cloud.points.resize (cloud.width * cloud.height);

    for (size_t i = 0; i < cloud.points.size (); ++i)
    {
        cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
        cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
        cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
    }

  这里要说明一下设置参数的问题。

参数

  pcl::PointCloud::width,在代码中显示的是 cloud.width =5,这是说,我们的点云有5个。它的目的是以点数指定点云数据集的宽度。 宽度有两个含义:

  • 它可以指定无组织数据集中云中的总点数(与点中的元素数量相等),官网的例子就是这样;
  • 它可以指定有组织的点云数据集的宽度(一行中的总点数)。

  这里说的,有组织的点云数据集是指向类似于有组织的图像(或矩阵)结构的点云的名称,其中数据被分成行和列。 这种点云的示例包括来自立体相机或飞行时间相机的数据。 有组织数据集的优点在于,通过了解相邻点(例如像素)之间的关系,最近邻操作更加有效,从而加速计算并降低PCL中某些算法的成本。

  可投影点云数据集是指给点云的名称,其具有根据组织点云中的点的 ( u , v ) (u,v) (uv)像素坐标与实际3D点之间的针孔相机模型的相关性,或对应关系。 这种相关性可以用最简单的形式表示为: u = f ∗ x / z u = f * x / z u=fx/z v = f ∗ y / z v = f * y / z v=fy/z。关于针孔模型相机,请看我的博文。


  pcl::PointCloud::height,在例子代码中,显示的是 cloud.height = 1。该处的意思是,以点数指定点云数据集的高度。 高度有两个含义:

  • 它可以指定有组织的点云数据集的高度(总行数);
  • 对于无组织数据集,它被设置为1(因此用于检查数据集是否有组织),就好比官网的例子一样。

  如果是有组织的,比如我们通过RGB-D相机给的深度图和彩色图,把像素点投影到3D上。我们可能这么设置:

cloud.width = 640; //图像是有组织的结构,有480行和640列,
cloud.height = 480; //因此数据集中总共640 * 480 = 307200点

  但是实际上,我们有时候用的时候,并没有指定,我们只需要在原来的数据集的push_back就可以了。因为cloud中用一个成员是 points。这个成员是这么定义的:

 std::vector<PointT, Eigen::aligned_allocator<PointT> > points;

  其实这也说明了,pcl脱离不了Eigen,而且它是一个vector类型,这就让我们直接push_back就可以了。

  而不是像官方例子这样,直接给明点的数量。

 cloud.points.resize (cloud.width * cloud.height);

  你只需要这么做:

 cloud.points.push_back(point);//point是pointT类型

  如果按照官网的例子,你的无组织的点云数据,大概就是这么指定的。

cloud.width = 307200;
cloud.height = 1; // 有307200 points的无组织点云数据集

  好了,就我们刚刚提到的话题,我们提到了。

  pcl::PointCloud::points,这是个 std::vector<PointT, Eigen::aligned_allocator<PointT> > 类型,我们把声明后面的Eigen忽略掉,你可以把它看成PointT的数组一样。我们可以说,pcl::PointCloud::points是包含存储PointT类型的所有点的数据数组。

  再来看看pcl::PointCloud::is_dense,代码中我们是 cloud.is_dense = false,这是指定点中的所有数据是否为有限(true),或某些点的XYZ值是否可能包含Inf / NaN值(false)。

  换句话说,如果没有点是无效的,则为true。这里的无效,举个例子,某个点在任一一个浮点字段中都有NaN或Inf值,就说这个点是无效的。


  我们其实进一步观察,还有一个参数,是 Eigen::Vector4f类型,这个参数名为 sensor_origin_,这个是什么意思?我自己一般不太常用,这是指定传感器采集姿势(原点/平移点)。 该成员通常是可选的,并且不被PCL中的大多数算法使用。也就是说,我们传感器,最初的时候是在什么地方,换个官方化的说法,就是当前数据坐标系中采集传感器的原点(位姿)


  再观察看看,还有一个成员,sensor_orientation_,这是个 Eigen::Quaternionf类型。也就是四元数类型。这是 4 × 1 4\times 1 4×1维的向量,用以表达旋转。这个参数是用来指定传感器采集位姿(方向),是可选的参数,并且不被PCL中的大多数算法使用。主要是表达传感器采集位姿(旋转)。

相信,你应该明白,前面这两个参数,都是表达位姿的,组合起来就是旋转+平移。也就是我们常说的矩阵T, [ R t 0 1 ] \begin{bmatrix}R&amp;t\\\boldsymbol{0}&amp;1\end{bmatrix} [R0t1]


  最后官网的例子里面还有这么个调用。

  pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);

  这主要是存储点云文件,我们把生成的点云放入到了cloud中,调用pcl的io就能存储。其实这个函数还有很多类似的,比如 savePCDFileBinarysavePCDFilesavePCDFileBinaryCompressed。其实选择一个合适就够了。

  好了,我们的剖析就这里为止了。

总结

  我们描述了PCL的例子和参数,但是PCL很多特性和描述没有说完,不过入门的情况下,感觉是够了。如果有看这部分知识的下去,我再更新,如果有人评论需要的话。以上的是我学习PCL的进展,PCL小白,从入门到放弃,额,说错,是精通。


  • 13
    点赞
  • 49
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YuYunTan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值