PCL Notes 1
2016-03-18 04:20
337 查看
Just start to learn PCL in C++. Previously I was justing using the PCL python bindings to do a little bit of calculations. However, encountered with the ray tracing problem, I did’t think Python PCL has it implemented.
width
height(set to 1 for unorganized datasets)
However, there is a helper function: isOrganized to check whether the point cloud is organized rather than checking heigh equals to 1 or not.
points(std::vector < PointT >)
is_dense: 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: specifies the sensor acquisition pose(origin/translation). This member is usually optional.
sensor_orientation:specifies the sensor acquisition pose(orientation). This member is usually optional.
`find_package(PCL 1.3 REQUIRED COMPONENTS common io): We are requesting to find the PCL package at minimum vision 1.3. We also say that it is REQUIRED meaning that cmake will fail gracefully if it can’t be found. As PCL is modular one can request:
only one component 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)
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 preprocess definition and compiler flags
To let cmake know about external headers you include in your project, one needs to use
We wrote the above codes in
Basic Structures
A point cloud is a C++ class which contains the following data fields:width
height(set to 1 for unorganized datasets)
However, there is a helper function: isOrganized to check whether the point cloud is organized rather than checking heigh equals to 1 or not.
points(std::vector < PointT >)
is_dense: 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: specifies the sensor acquisition pose(origin/translation). This member is usually optional.
sensor_orientation:specifies the sensor acquisition pose(orientation). This member is usually optional.
Compiling the codes:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR) project(MY_GRAND_PROJECT) find_package(PCL 1.3 REQUIRED COMPONENTS common io) include_directories(${PCL_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS}) add_executable(pcd_write_test pcd_write.cpp) target_link_libraries(pcd_write_test ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
cmake_minimum_requiredis mandatory for cmake
project(MY_GRAND_PROJECT)names your project and sets some useful make variables such as those to refer to the source directory(MY_GRAND_PROJECT_SOURCE_DIR) and the directory from which you are invoking cmake (MY_GRAND_PROJECT_BINARY_DIR).
`find_package(PCL 1.3 REQUIRED COMPONENTS common io): We are requesting to find the PCL package at minimum vision 1.3. We also say that it is REQUIRED meaning that cmake will fail gracefully if it can’t be found. As PCL is modular one can request:
only one component 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)
include_directories,
link_directories,
add_definitions: 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 preprocess definition and compiler flags
To let cmake know about external headers you include in your project, one needs to use
include_directories()macro. In our case PCL_INCLUDE_DIRS, contains exactly what we need, thus we ask cmake to search the path it contains for a header potentially included.
add_executable: Here, we tell cmake that we are trying to make an executable file named pcd_write\ _test from one single source file pcd_write.cpp. CMake will take care of the suffix and the permissions.
target_link_libraries(): The executable we are building makes call to PCL functions. So far, we have only included the PCL headers so the compilers knows about the methods we are calling. We need also to make the linker know about the libraries we are linking against. As said before, PCL found libraries referred to using PCL_LIBRARIES variables, all that remains is to trigger the link operation which we do calling
target_link_libraries()macro.
#include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/point_types.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); }
We wrote the above codes in
pcd_write.cpp.
相关文章推荐
- 计算机视觉领域的牛人博客和有实力的研究机构
- 科研工作的关注点
- 从PCD文件中读取点云数据
- 向pcd文件写入点云数据
- VS2010(64)+Qt4.8.0+PCL1.6.0+Vtk配置显示点云
- 基于轮廓的三维骨架重建方法和核心代码
- 最小外接矩形(MBR)
- 色彩量化评价指标 Quantitative measure methods for color quantization
- 图像处理的网址(转载)
- OpenCV学习笔记 第一篇 显示图像
- 图铭Android平台银行卡号识别系统
- 学习OpenCV第一课——认识、安装配置OpenCV(CodeBlocks)
- Kalman滤波
- 图像处理特征不变算子系列之KLT算子--GoodFeaturesToTrack(七)
- 《计算机视觉中的数学方法》笔记1 向量叉积的反对称矩阵表示
- 摄像测量相关
- Learning OpenCV Chapter3 初探OpenCV上
- 开通博客--for interest
- 计算机视觉投稿
- 摄像机几何概念