pcl之I/O輸入輸出
阿新 • • 發佈:2018-11-20
res resize height trying char eight eat pcl ++
pcl之I/O輸入輸出
Reading Point Cloud data from PCD files
#include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/point_types.h> int main (int argc, char** argv) { pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); if (pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud) == -1) //* load the file { PCL_ERROR ("Couldn't read file test_pcd.pcd \n"); return (-1); } return (0); }
Writing Point Cloud data to PCD files
#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); }
Concatenate the points of two Point Clouds
- If we are trying to concatenate points then the code below:
cloud_c = cloud_a;
cloud_c += cloud_b;
creates cloud_c by concatenating the points of cloud_a and cloud_b together.
- Otherwise if we are attempting to concatenate fields then the code below:
pcl::concatenateFields (cloud_a, n_cloud_b, p_n_cloud_c);
creates p_n_cloud_c by concatenating the fields of cloud_a and cloud_b together.
pcl之I/O輸入輸出