002:pcl 点云投影
发布时间:2020-12-16 09:12:24 所属栏目:百科 来源:网络整理
导读:1.首先包含的对应的ModelCoefficients.h以及filter中向平面投影的project_inlier.h #include iostream#include pcl/io/pcd_io.h#include pcl/point_types.h#include pcl/ModelCoefficients.h#include pcl/filters/project_inliers.h 2.创建点云对象指针并初
1.首先包含的对应的ModelCoefficients.h以及filter中向平面投影的project_inlier.h #include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/point_types.h> #include <pcl/ModelCoefficients.h> #include <pcl/filters/project_inliers.h> 2.创建点云对象指针并初始化,输出到屏幕 /2.初始化该对象 ? cloud->width? = 5;//对于未组织的点云的相当于points个数 ? cloud->height = 1; //对未组织的点云指定为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); ? } ? // 3.cerr 输出对象放置刷屏 ? 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; //投影前点 `Cloud before projection: 1.28125 577.094 197.938 828.125 599.031 491.375 358.688 917.438 842.563 764.5 178.281 879.531 727.531 525.844 311.281 3.设置ModelCoefficients值。在这种情况下,我们使用一个平面模型,其中ax + by + cz + d = 0,其中a = b = d = 0,c = 1,或者换句话说,XY平面 ? // 4.创建一个系数为X=Y=0,Z=1的平面 ? pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ()); ? coefficients->values.resize (4); ? coefficients->values[0] = coefficients->values[1] = 0; ? coefficients->values[2] = 1.0; ? coefficients->values[3] = 0; 4.通过该滤波将所有的点投影到创建的平面上,并输出结果 ? //5.创建滤波后对象,并通过滤波投影,并显示结果 ? pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected(new pcl::PointCloud<pcl::PointXYZ>); ? // 创建滤波器对象 ? 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); //投影后点 Cloud before projection: 1.28125 577.094 197.938 828.125 599.031 491.375 358.688 917.438 842.563 764.5 178.281 879.531 727.531 525.844 311.281 Cloud after projection: 1.28125 577.094 0 828.125 599.031 0 358.688 917.438 0 764.5 178.281 0 727.531 525.844 0 6.参考网址 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – 在Rspec中,如何测试没有路由的控制器操作
- nosql – CouchDB和Couchbase之间的区别
- ios – 应用程序和扩展 – 使用核心数据==错误:sharedAppl
- PostgreSQL和顺序数据
- 如果Ruby和Python都允许进行猴子补丁,那为什么Ruby更有争议
- Binary XML file line #13: Duplicate id 0x7f070055, tag
- 正则表达式 验证YYYY-MM-DD HH:mm:ss,包含闰年验证(包含世
- pyinstaller 生成单一的EXE文件之后获取当前目录的方法
- AlertDialog对话框
- C# HttpClient 请求认证、数据传输笔记