PCD ํŒŒ์ผ์„ ์ฝ์–ด๋ณด์ž
ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ

์ „์ฒด ์ฝ”๋“œPermalink

#include <iostream>

// ํ—ค๋” ํŒŒ์ผ ์„ ์–ธ
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

using namespace std;

int main(int argc, char** argv)
{
  // PCD ํŒŒ์ผ์„ ๋‹ด์„ Object ์„ ์–ธ
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>());

  // 2๊ฐ€์ง€ ๋ฐฉ๋ฒ• ์กด์žฌ
  // 1. loadPCDFilie ํ•จ์ˆ˜๋ฅผ ์ด์šฉ
  if (pcl::io::loadPCDFile("../before_proj.pcd", *cloud) == -1)
  {
    PCL_ERROR("Couldn't read the pcd file");
    return -1;
  }

  // 2. PCDReader๋ฅผ ์ด์šฉ 
  pcl::PCDReader reader;
  reader.read("../before_proj.pcd", *cloud);

  cout << "pc size: " << cloud->width * cloud->height << endl;

  for(auto& point: *cloud)
  {
    cout << "x: " << point.x << " "
    << "y: " << point.y << " "
    << "z: " << point.z << endl;
  }
  return 0;
}

ReferencePermalink

Leave a comment