如何在PCL(带有Qt)中可视化TOF传感器数据序列? [英] How to visualize a sequence of TOF-Sensor data in PCL (with Qt)?
问题描述
我有这个TOF传感器,我想将传感器的数据可视化为Qt中的点云.我将数据转换为pcl::PointCloud
,现在我想将其可视化.
I've this TOF-sensor and I want to visualize the sensor's data as a point-cloud in Qt. I converted the data into a pcl::PointCloud
and now I want to visualize it.
每创建一个传感器,API就会发出一幅图像.然后将其发送到QVTKWidget
进行可视化.然后,我尝试使用此代码段(从此处获得):
The API of the sensor would emit a picture whenever one was created. And I would send it to the QVTKWidget
to visualize it. And I tried it with this snippet of code (which I got from here):
pcl::visualization::PCLVisualizer pvis ("test_vis", false);
// 'false' prevents PCLVisualizer's own window to pop up
pvis.addPointCloud<pcl::PointXYZ>(pc); // pc is my point cloud
vtkSmartPointer<vtkRenderWindow> renderWindow = pvis.getRenderWindow();
widget.SetRenderWindow(renderWindow);
但是,这似乎只是为了可视化一个稳定的点云,而不是点云的变化序列.
But it seems like this is only meant to visualize one steady point-cloud and not a changing sequence of point-clouds.
问题:每当我的传感器发出新图片时,有什么方法可以更新cloud_xyz
吗?
Question: Is there any way to update the cloud_xyz
whenever my sensor emits a new picture?
推荐答案
好的,经过一番尝试,这是我的解决方案:
OK, after some trying, here is my solution:
继承自QVTKWidget
:
pcl::visualization::PCLVisualizer vis ("vis", false);
VTKPointCloudWidget::VTKPointCloudWidget(QWidget *parent) : QVTKWidget(parent)
{
this->resize(500, 500);
pcl::PointCloud<pcl::PointXYZ>::Ptr pc (new pcl::PointCloud<pcl::PointXYZ>);
vis.addPointCloud<pcl::PointXYZ>(pc);
vtkSmartPointer<vtkRenderWindow> renderWindow = vis.getRenderWindow();
this->SetRenderWindow(renderWindow);
this->show();
}
,每当发出新的传感器图像时,它就会发送到:
and whenever a new sensor image is emitted, it is sent to:
void VTKPointCloudWidget::showPointCloud(SensorPicture pic)
{
// converts the sensor image to a point cloud
pcl::PointCloud<pcl::PointXYZ>::Ptr pc = cvtSP2PC(pic);
pc->width = pic.width;
pc->height = pic.height;
vis.updatePointCloud<pcl::PointXYZ>(pc);
this->update();
}
这篇关于如何在PCL(带有Qt)中可视化TOF传感器数据序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!