PCL编译过程

PCL是一套开源的点云处理工具/类库,网上看到一些很酷的3D处理视频,比如:微软Kinect扫描建立3D模型,在PCL上可以找到现成的例子。然而官网提供的windows安装包是1.6.0版本,很多有用的APP没有编译,所以不得已只能自己动手了。还是得吐槽一下,PCL的编译过程太繁琐,文档也没有好的说明。

前期准备:

  • 源码:从http://pointclouds.org/downloads上找github的链接
  • 第三方库:PCL依赖几个第三方库,为了图简单我没有逐个编译这些第三方库,而是选择了安装all-in-one installer和QT 4.8.0,cmake-2.8.x,GTest

编译过程:

  1. 运行cmake-gui,选择好源码位置和工作目录位置,然后点击configurate,我的输出如下,可以作为参考。
  2. 点击generate,可能会提示找不到PDB文件,如果不需要调试信息的话,可以忽略这些warning。
Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE) 
Found OpenMP
Boost version: 1.49.0
Found the following Boost libraries:
  system
  filesystem
  thread
  date_time
  iostreams
  chrono
Eigen found (include: D:\Program Files\PCL 1.6.0\3rdParty\Eigen\include, version: 3.0.3)
FLANN found (include: D:/Program Files/PCL 1.6.0/3rdParty/FLANN/include, lib: optimized;D:/Program Files/PCL 1.6.0/3rdParty/FLANN/lib;debug;D:/Program Files/PCL 1.6.0/3rdParty/FLANN/lib)
Could NOT find LIBUSB_1 (missing:  LIBUSB_1_LIBRARY LIBUSB_1_INCLUDE_DIR) 
OpenNI found (include: D:\Program Files\OpenNI\Include, lib: D:\Program Files\OpenNI\Lib)
OpenNI 2 found (include: D:/Program Files/OpenNI2/Include, lib: D:/Program Files/OpenNI2/Lib/OpenNI2.lib, redist: D:\Program Files\OpenNI2\Redist\)
Could NOT find FZAPI (missing:  FZAPI_LIBS FZAPI_INCLUDE_DIR) 
Could NOT find ensenso (missing:  ENSENSO_LIBRARY ENSENSO_INCLUDE_DIR) 
Could NOT find davidSDK (missing:  DAVIDSDK_LIBRARY DAVIDSDK_INCLUDE_DIR) 
Could NOT find PXCAPI (missing:  PXCAPI_LIBS PXCAPI_INCLUDE_DIRS) 
Could NOT find ZLIB (missing:  ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
Could NOT find PNG (missing:  PNG_LIBRARY PNG_PNG_INCLUDE_DIR) 
QHULL found (include: D:/Program Files/PCL 1.6.0/3rdParty/Qhull/include, lib: optimized;D:\Program Files\PCL 1.6.0\3rdParty\Qhull\lib;debug;D:\Program Files\PCL 1.6.0\3rdParty\Qhull\lib)
Qt QTGUI library not found.
VTK_MAJOR_VERSION 5
VTK found (include: D:/Program Files/PCL 1.6.0/3rdParty/VTK/include/vtk-5.8;D:/Program Files/PCL 1.6.0/3rdParty/VTK/include/vtk-5.8, lib: D:/Program Files/PCL 1.6.0/3rdParty/VTK/lib/vtk-5.8;D:/Program Files/PCL 1.6.0/3rdParty/VTK/lib/vtk-5.8)
Could NOT find PCAP (missing:  PCAP_LIBRARIES PCAP_INCLUDE_DIRS) 
Qt QTOPENGL library not found.
Qt QTGUI library not found.
Qt QTGUI library not found.
PCL_EXAMPLES_SUBDIRS E:/phil/ws/structureio/pcl-master/examples/common/;E:/phil/ws/structureio/pcl-master/examples/features/;E:/phil/ws/structureio/pcl-master/examples/filters/;E:/phil/ws/structureio/pcl-master/examples/geometry/;E:/phil/ws/structureio/pcl-master/examples/keypoints/;E:/phil/ws/structureio/pcl-master/examples/outofcore/;E:/phil/ws/structureio/pcl-master/examples/segmentation/;E:/phil/ws/structureio/pcl-master/examples/stereo/;E:/phil/ws/structureio/pcl-master/examples/surface/
GTest found (include: D:\Program Files\PCL 1.6.0\3rdParty\gtest-1.7.0\include, src: D:/Program Files/PCL 1.6.0/3rdParty/gtest-1.7.0)
DOXYGEN_FOUND 
HTML_HELP_COMPILER 
Found CPack generators: NSIS
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
  apps
       building: 
       |_ 3d_rec_framework
       |_ in_hand_scanner
       |_ modeler
       |_ point_cloud_editor
       not building: 
       |_ cloud_composer: No reason
       |_ optronic_viewer: FZAPI was not found.
  outofcore
  examples
  people
  global_tests
  tools
The following subsystems will not be built:
  simulation: Requires external library glew.
Configuring done

几个值得注意到地方,如果Qt没有安装到默认的位置”C:\Qt\”,那么需要修改VTK目录下VTKConfigQt.cmake,VTKTargets-debug.cmake,VTKTargets-release.cmake,将Qt目录修改为你实际安装的目录即可。另外,cmake是根据qmake的信息寻找qt库路径,所以还得在qmake所在路径下新建一个qt.conf文件,增加qt的安装路径,示例如下:

[Paths]
Prefix = D:\\Qt\\4.8.0

配置的过程很繁琐,注意error提示,一个个解决。编译过程中还会遇到几个问题,凭印象列举一下吧。

  • 找不到Qt的头文件,因为Qt4和Qt5有区别,简单解决办法是在include头文件的时候加上QtGui或者QtOpenGL。如:“#include <QtOpenGL/QtOpenGL>”
  • 如果遇到链接错误很可能是没有将第三方库加到链接选项里面去,解决办法,自己修改VS工程的链接选项。

PCL官网:http://pointclouds.org/

如何判断当前网页是否用微信打开

微信打开的网页对下载apk的链接进行了屏蔽,如果没有通过腾讯开放平台“上架”的应用一律不能用微信打开的网页下载。所以有人就做了一个提示,提示用户用浏览器打开网页并下载。如何判断是否为微信打开的网页呢?见下面这个例子

<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {
    $("#download_android").attr("href","#");
    $("#download_android").click(function(){
        $("#navi").show();
    });
} else {
}
</script>