0

我将 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 将自定义颜色应用于切片点。

任何建议表示赞赏!

4

1 回答 1

0

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

于 2018-12-11T12:47:28.587 回答