PCL(点云库)common模块学习(一)

pcl::CentroidPoint< PointT > 

//Module common学习
//pcl::CentroidPoint< PointT > 类
//计算点的质心
//类成员函数(3个)
//void pcl::CentroidPoint< PointT >::add	(	const PointT & 	point	)	
//void pcl::CentroidPoint< PointT >::get	(	PointOutT & 	point	)	const
//size_t pcl::CentroidPoint< PointT >::getSize	(		)	const

#include            		//标准C++库中输入输出类相关头文件
#include   		//PCL中支持的点类型头文件
#include 	//CentroidPoint的头文件,为啥这么写是看的API手册

int main (int argc, char** argv)
{
	// Create and accumulate points
	pcl::CentroidPoint centroid;
	centroid.add (pcl::PointXYZ (1, 2, 3));//成员函数add用法
	centroid.add (pcl::PointXYZ (5, 6, 7));
	//输出加入点的数目
	std::cerr << "The total number of points that were added is: " << centroid.getSize() <<  std::endl;//成员函数getSize()用法
	// Fetch centroid using `get()`
	pcl::PointXYZ c1;
	centroid.get (c1);//成员函数get用法
	// The expected result is: c1.x == 3, c1.y == 4, c1.z == 5
	// It is also okay to use `get()` with a different point type
	//输出结果
	std::cerr << "The expected result(  PointXYZ ) is: c1.x = " << c1.x << ", c1.y = " << c1.y << ", c1.z = " << c1.z << std::endl;
	//更换一种PointType
	pcl::PointXYZRGB c2;
	centroid.get (c2);
	// The expected result is: c2.x == 3, c2.y == 4, c2.z == 5,
	// and c2.rgb is left untouched
	//输出结果
	std::cerr << "The expected result(PointXYZRGB) is: c2.x = " << c2.x << ", c2.y = " << c2.y << ", c2.z = " << c2.z << std::endl;
  	return (0);
}



cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(test)

find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

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

 

你可能感兴趣的:(PCL,C++,PCL学习)