Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Point Cloud Library: Sliced points to custom colors
Forum Updated to NodeBB v4.3 + New Features

Point Cloud Library: Sliced points to custom colors

Scheduled Pinned Locked Moved Solved Mobile and Embedded
qt 5.7vtkpcl
2 Posts 1 Posters 923 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sayan275
    wrote on last edited by
    #1

    I'm using pcl and vtk library with Qt for point cloud visualization. My setup is as the below link http://unanancyowen.com/en/pcl-with-qt/

    Now when we slice points ie, press 'x' and select a region by AreaPickingEvent and that selected sliced points become red colored. It's done by the following function

    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;
    

    Now if we pass GROUND_POINT it becomes blue color, which is used for Plane detect or threshold.

    Now my requirement is to color the sliced points as the user defines it. How can I apply my custom color to the sliced points by pcl::RGB.

    Any suggestion is appreciated!!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sayan275
      wrote on last edited by
      #2

      we can change the rgb values of each point in a cloud

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved