当前位置:网站首页>PCL projection point cloud
PCL projection point cloud
2022-07-02 10:57:00 【AICVer】
Projection to XOY In the plane
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/filters/project_inliers.h>
#include <pcl/visualization/pcl_visualizer.h>
using namespace std;
using namespace pcl;
void visualize(PointCloud<PointXYZ>::Ptr source, PointCloud<PointXYZ>::Ptr target)
{
visualization::PCLVisualizer viewer("Point Cloud Viewer");
// Create two display windows
int v1, v2;
viewer.createViewPort(0, 0.0, 0.5, 1.0, v1);
viewer.createViewPort(0.5, 0.0, 1.0, 1.0, v2);
// Set the background color
viewer.setBackgroundColor(255, 255, 255, v1);
viewer.setBackgroundColor(255, 255, 255, v2);
// Add color to point clouds
visualization::PointCloudColorHandlerCustom<PointXYZ> source_color(source, 0, 0, 255); // blue
visualization::PointCloudColorHandlerCustom<PointXYZ> target_color(target, 255, 0, 0); // red
// Add a point cloud to the display window
viewer.addPointCloud(source, source_color, "source cloud", v1);
viewer.addPointCloud(target, target_color, "target cloud", v2);
while (!viewer.wasStopped())
{
viewer.spinOnce(100);
boost::this_thread::sleep(boost::posix_time::microseconds(100000));
}
}
int main(int argc, char** argv)
{
PointCloud<PointXYZ>::Ptr cloud(new pcl::PointCloud<PointXYZ>);
PointCloud<PointXYZ>::Ptr filtered_cloud(new pcl::PointCloud<PointXYZ>);
io::loadPCDFile("D:\\Data\\rabbit.pcd", *cloud);
// Output the number of points before filtering
cout << " Before filtering :" << cloud->points.size() << " A little bit " << endl;
// Set the coefficient of model parameters
ModelCoefficients::Ptr coefficients(new ModelCoefficients());
coefficients->values.resize(4);
coefficients->values[0] = 0;
coefficients->values[1] = 0;
coefficients->values[2] = 1.0;
coefficients->values[3] = 0;
// Instantiate the filter object
ProjectInliers<PointXYZ> proj;
proj.setModelType(SACMODEL_PLANE);
proj.setInputCloud(cloud);
proj.setModelCoefficients(coefficients);
proj.filter(*filtered_cloud);
cout << " Yes after filtering :" << filtered_cloud->points.size() << " A little bit " << endl;
visualize(cloud, filtered_cloud);
return 0;
}
Other models that can be projected
The projection models that can be used are as follows :
Plane model :SACMODEL_PLANE
Line model :SACMODEL_LINE
A two-dimensional circle on a plane :SACMODEL_CIRCLE2D
A three-dimensional circle on a plane :SACMODEL_CIRCLE3D
Sphere model :SACMODEL_SPHERE
Cylinder model :SACMODEL_CYLINDER
Conical model :SACMODEL_CONE
Torus model :SACMODEL_TORUS
A line model parallel to a given axis :SACMODEL_PARALLEL_LINE
Plane model perpendicular to the specified axis :SACMODEL_PERPENDICULAR_PLANE
3D bar segmentation model :SACMODEL_STICK
边栏推荐
猜你喜欢

js数组常用方法
![[SUCTF2018]followme](/img/63/9104f9c8bd24937b0fc65053efec96.png)
[SUCTF2018]followme

拆解美图SaaS:开着飞机换引擎

LabVIEW为什么浮点数会丢失精度

Dialogue Wu Gang: why do I believe in the rise of "big country brands"?

MongoDB 学习整理(条件操作符,$type 操作符,limit()方法,skip() 方法 和 sort() 方法)

Introduction to MySQL 8 DBA foundation tutorial

UVM learning - build a simple UVM verification platform

Kustomize user manual

如何使用IDE自动签名调试鸿蒙应用
随机推荐
14. Code implementation of semaphore
MYSQL关键字
【ARK UI】HarmonyOS ETS的启动页的实现
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
Session cookies and tokens
Start class, data analysis, high salary training plan, elite class
Lunix reallocates root and home space memory
2. Hacking lab script off [detailed writeup]
14.信号量的代码实现
02-taildir source
618再次霸榜的秘密何在?耐克最新财报给出答案
互联网快讯:腾讯会议应用市场正式上线;Soul赴港递交上市申请书
软件产品管理系统有哪些?12个最佳产品管理工具盘点
618 what is the secret of dominating the list again? Nike's latest financial report gives the answer
UVM factory mechanism
Pywin32 opens the specified window
PCL Eigen介绍及简单使用
Flutter环境配置保姆级教程,让doctor一绿到底
JSP webshell免杀——webshell免杀
UVM——Callback