pcl 点投影到某个平面

来源:互联网 发布:恒扬数据股份有限公司 编辑:程序博客网 时间:2024/06/06 10:42

官方教程
http://pointclouds.org/documentation/tutorials/project_inliers.php#project-inliers
代码:

#include <iostream>#include <pcl/io/pcd_io.h>#include <pcl/point_types.h>#include <pcl/ModelCoefficients.h>#include <pcl/filters/project_inliers.h>intmain(int argc, char** argv){    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected(new pcl::PointCloud<pcl::PointXYZ>);    // Fill in the cloud data    cloud->width = 5;    cloud->height = 1;    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);    }    std::cerr << "Cloud before projection: " << 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;    // Create a set of planar coefficients with X=Y=0,Z=1    pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());    coefficients->values.resize(4);    coefficients->values[0] = 1;    coefficients->values[1] = 0;    coefficients->values[2] = 0;    coefficients->values[3] = 0;    // Create the filtering object    pcl::ProjectInliers<pcl::PointXYZ> proj;    proj.setModelType(pcl::SACMODEL_PLANE);    proj.setInputCloud(cloud);    proj.setModelCoefficients(coefficients);    proj.filter(*cloud_projected);    std::cerr << "Cloud after projection: " << std::endl;    for (size_t i = 0; i < cloud_projected->points.size(); ++i)        std::cerr << "    " << cloud_projected->points[i].x << " "        << cloud_projected->points[i].y << " "        << cloud_projected->points[i].z << std::endl;    return (0);}

window vs调试的错误解决办法
http://blog.csdn.net/wokaowokaowokao12345/article/details/51287011
中文翻译理解
http://www.pclcn.org/study/shownews.php?lang=cn&id=71

0 0
原创粉丝点击