PCL 점 클라우드 파일 읽기 및 저장
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
if (pcl::io::loadPCDFile<pcl::PointXYZRGBA> ("test_pcd.pcd", *cloud) == -1) //* load the file
{
PCL_ERROR ("Couldn't read file test_pcd.pcd
");
return (-1);
}
std::cout << "Loaded "
<< cloud->width * cloud->height
<< " data points from test_pcd.pcd with the following fields: "
<< std::endl;
for (size_t i = 0; i < cloud->points.size (); ++i)
std::cout << " " << cloud->points[i].x
<< " " << cloud->points[i].y
<< " " << cloud->points[i].z
<< " " << (int)cloud->points[i].r
<< " " << (int)cloud->points[i].g
<< " " << (int)cloud->points[i].b
<< std::endl;
std::string filename("test.pcd");
pcl::PCDWriter writer;
writer.write(filename,*cloud);
return (0);
}
주의: 프로그램과 같이 컨트롤러에 r, g, b 정보를 표시하려면 r, g, b의 형식을 강제로 변환해야 합니다.