点云库:将点切片为自定义颜色



我将pcl和vtk库与Qt一起用于点云可视化。我的设置如下链接http://unanancyowen.com/en/pcl-with-qt/

现在,当我们切片点时,即,按"x"并通过AreaPickingEvent选择一个区域,所选的切片点将变为红色。这是通过以下功能完成的

void PointCloudVisualizer::highlightPoint(std::vector<int>& slice)
{
if (slice.size()<1) return;
for (std::vector<int>::iterator it = slice.begin(); it != slice.end(); it++)    {
m_cloudLabel[*it] = SELECTED_POINT;//SELECTED_POINT = 1
}
}
void PointCloudVisualizer::updateCloud()
{
m_pViewer->updatePointCloud<PointT>(m_pCloud, m_pColorHandler, m_sCurrentPointCloudId.toStdString());
m_pPointCloudVisualizerUI->qvtkWidget->update();
}
//area picking event, after the points are sliced we call these 2 functions and the sliced points gets red
void PointCloudVisualizer::AreaPickingEventProcess(const pcl::visualization::AreaPickingEvent& event)
{
vector<int> newSelectedSliceVector;
event.getPointsIndices(newSelectedSliceVector);
if (newSelectedSliceVector.empty()) return;
// remove ground points
vector<int> groundPointsVector;
for (auto point : newSelectedSliceVector)
{
if (m_cloudLabel[point] != GROUND_POINT)
{
groundPointsVector.push_back(point);
}
}
.
.
.
newSelectedSliceVector = groundPointsVector;
m_lastSelectedSliceVector = newSelectedSliceVector;
.
.
.
highlightPoint(m_lastSelectedSliceVector);//red color selected points
updateCloud();
.
.
.
}
//other variables
int* m_cloudLabel;
PointCloudTPtr m_pCloud;
//initializing m_cloudLabel
m_cloudLabel = new int[m_pCloud->size()];
memset(m_cloudLabel, 0, m_pCloud->size()*sizeof(int));
m_pColorHandler.setInputCloud(m_pCloud);
m_pColorHandler.setLabel(m_cloudLabel);
//----------------------------------------
const int DEFAULT_POINT =  0;
const int SELECTED_POINT = 1;
const int GROUND_POINT = 2;

现在,如果我们通过GROUND_POINT,它将变为蓝色,用于平面检测或阈值。

现在,我的要求是根据用户的定义为切片点上色。如何通过pcl::RGB将自定义颜色应用于切片点。

欢迎提出任何建议!!

点云处理程序维护一个用于为切片点着色的颜色LUT(查找表(。更新了颜色LUT并称为highlightPoints,其中SELECTED_POINT索引随着用户选择颜色而更新。

最新更新