登录 | 注册


RangeImage visualization modules 深度图像可视化模块

The PCL Visualization library is meant to integrate PCLwith VTK, by providing a comprehensive visualization layer for n-D point cloud structures.与VTK集成在一起



1.   安装Microsoft VisualStudio 2010;

2.   安装PCL-1.6.0-AllInOne-msvc2010-win32;






3.   安装cmake-2.8.9win32-x86;选择英文路径




Writing Point Cloud data to PCD files tutorial). In the same folder, create a file named CMakeLists.txt that contains:

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})

没找到上面文件,PATH下新建一Project目录,把D:\Program Files\PCL 1.6.0\share\doc\pcl-1.6\tutorials\sources下的pcd_write.cpp和CMakeLists.txt拷贝到当前目录,其内容如下

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)


find_package(PCL 1.2 REQUIRED)


add_executable (pcd_write pcd_write.cpp)
target_link_libraries (pcd_write ${PCL_LIBRARIES})



对cmake是强制的, 因为是基本项目,编译器版本.

这一行命名项目并设置一些有用的cmake 变量,例如与源文件目录相关(pcd_write_SOURCE_DIR) and the directory from which you are invoking cmake (pcd_write_BINARY_DIR).

请求找到最低版本为1.0PCL 包. 这是必须项REQUIRED 的意思,如果不能找到否则cmake将完全失效 . As PCL is modular one can request:

  • 只有一个组件: find_package(PCL 1.3 REQUIRED COMPONENTS io)
  • several: find_package(PCL 1.3 REQUIRED COMPONENTS io common)
  • all existing: find_package(PCL 1.3 REQUIRED)

When PCL is found, several related variables are set:

  • PCL_FOUND: set to 1 if PCL is found, otherwise unset
  • PCL_INCLUDE_DIRS: set to the paths to PCL installed headers and the dependency headers
  • PCL_LIBRARIES: set to the file names of the built and installed PCL libraries
  • PCL_LIBRARY_DIRS: set to the paths to where PCL libraries and 3rd party dependencies reside
  • PCL_VERSION: the version of the found PCL
  • PCL_COMPONENTS: lists all available components
  • PCL_DEFINITIONS: lists the needed preprocessor definitions and compiler flags

为了让 cmake知道你在项目里包含的外部头文件, 需使用include_directories() 宏. 在我们的PCL_INCLUDE_DIRS,宏, 完全包含了我们所需要的, 我们让cmake  查找它可能包含的头文件.

告诉cmake我们尝试生成一个可执行文件,名字是pcd_write 从一个单一的源文件pcd_write.cpp. CMake 会注意生成的后缀名suffix (.exe on Windows platform and blank on UNIX) and the permissions.

我们生成的可执行文件调用 PCL 函数. 到现在, 我们只包含了PCL头文件,所以编译器知道我们调用的方法. 我们也需要让连接器知道我们链接所依赖的库文件. 如前所述, PCL 通过使用PCL_LIBRARIES 变量寻找相关库文件, all that remains is to trigger the link operation which we do calling target_link_libraries() macro. PCLConfig.cmake uses a CMake special feature named EXPORT which allows for using others’ projects targets as if you built them yourself. When you are using such targets they are called imported targets and acts just like anyother target.


使用图形界面CMake (e.g. Windows),你也可以使用命令行CMake。

运行CMake 图形界面, 填充以下字段:

  • 源代码路径: 包含CMakeLists.txt 文件和源文件文件夹.
  • 要生成的二进制文件路径: 要生成的Visual Studio工程文件的文件夹

设置好之后单击Configure. 将提示a generator/compiler. 然后单击Generate 按钮. 如果没有错误,工程文件就会生成在上面设置的二进制文件路径.

打开sln 文件, build your project!






Getting Started / Basic Structures

PCL 1.x 中基本数据类型是 PointCloud.  PointCloud 是一个 C++ 类,包含如下几个数据域:

  • width (int)

    从点的数量上指定点云数据集的宽度. width 有两层意思:

    • 指定不规则点云中点的总数(equal with the number of elements in points – see below) ;
    • 指定规则点云数据集的宽度(total number of points in a row).


    An organized point cloud dataset is the name given to point clouds that resemble an organized image (or matrix) like structure, where the data is split into rows and columns. Examples of such point clouds include data coming from stereo cameras or Time Of Flight cameras. The advantages of a organized dataset is that by knowing the relationship between adjacent points (e.g. pixels), nearest neighbor operations are much more efficient, thus speeding up the computation and lowering the costs of certain algorithms in PCL.


    An projectable point cloud dataset is the name given to point clouds that have a correlation according to a pinhole camera model between the (u,v) index of a point in the organized point cloud and the actual 3D values. This correlation can be expressed in it’s easiest form as: u = f*x/z and v = f*y/z


    cloud.width = 640; // there are 640 points per line
  • height (int)

    从点的数量上指定点云数据集的高度. height has two meanings:

    • 指定规则点云数据集的高度(行的总数目);
    • 不规则点云设置为1 (用来检查数据集是否规则).


    cloud.width = 640; // Image-like organized structure, with 640 rows and 480 columns,
    cloud.height = 480; // thus 640*480=307200 points total in the dataset


    cloud.width = 307200;
    cloud.height = 1; // unorganized point cloud dataset with 307200 points
  • points (std::vector<PointT>)

    数据数组,存储所有的PointT类型点数据. 比如, 对于一个包含XYZ 数据的点云, points 包含一个pcl::PointXYZ向量:

    pcl::PointCloud<pcl::PointXYZ> cloud;
    std::vector<pcl::PointXYZ> data = cloud.points;
  • is_dense (bool)

    Specifies if all the data in points is finite (true), or whether the XYZ values of certain points might contain Inf/NaN values (false).

  • sensor_origin_ (Eigen::Vector4f)

    Specifies the sensor acquisition pose (origin/translation). This member is usually optional, and not used by the majority of the algorithms in PCL.

  • sensor_orientation_ (Eigen::Quaternionf)

    Specifies the sensor acquisition pose (orientation). 通常情况下是可选的, PCL大部分算法不会用到.

为简化开发, PointCloud 类包含一系列帮助函数. 例如, 用户不必在代码中检查height 是否为1以此来判断数据集是规则还是不规则, 相反使用PointCloud():

if (!cloud.isOrganized ())

PointT 是基本的点数据类型,描述了每个点元素所拥有的基本特性 . PCL 有大量各不相同的点类型, 大部分在Adding your own custom PointT type tutorial进行了解释说明.

Compiling your first code example

Until we find the right minimal code example, please take a look at the Using PCL in your own project and Writing a new PCL class tutorials to see how to compile and write code for or using PCL.


2020 jeepxie.net webmaster#jeepxie.net
10 q. 0.009 s.