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

Point Cloud Library: Sliced points to custom colors

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

现在当我们切片点时,即按 'x' 和 select 一个区域 AreaPickingEvent 然后selected切片点变成红色。它是由以下函数完成的

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(查找 table),用于为切片点着色。 更新了颜色 LUT 并调用了 highlightPoints,其中 SELECTED_POINT 索引随着用户选择颜色而更新。