1

나는 스테레오 카메라를 사용하여 평면을 스캔하여 포인트 클라우드를 생성했습니다. 법선, fpfh 등의 기능을 생성했으며이 정보를 사용하여 포인트 클라우드의 영역을 분류하려고합니다. 보다 전통적인 CNN 접근 방식을 사용하려면이 pointcloud를 opencv의 다중 채널 이미지로 변환하고 싶습니다. 포인트 클라우드를 XY 평면에 접어서 X 및 Y 축에 정렬하여 이미지의 경계 상자를 만들 수 있습니다.포인트 클라우드를 깊이/다중 채널 이미지로 변환

나는 포인트에서 픽셀로 매핑하는 방법에 대한 아이디어를 찾고 있습니다. 특히 이미지 크기와 각 픽셀을 적절한 데이터로 채우는 방법에 대해 혼란스러워합니다. 겹치는 점은 평균화되고 빈 점은 그에 따라 분류됩니다. 이것은 조직화되지 않은 포인트 클라우드이기 때문에 사용할 카메라 매개 변수가 없으며 PCL의 RangImage 클래스가 제 경우에는 작동하지 않을 것으로 생각됩니다.

도움을 주시면 감사하겠습니다.

답변

0

미리 지정된 크기의 빈 cv :: Mat를 만들어보십시오. 그런 다음 Mat의 모든 픽셀을 반복하여 어떤 값을 취해야하는지 결정합니다. 여기

은 유사한 무언가를 몇 가지 코드 무엇인지는 설명했다 :

cv::Mat makeImageFromPointCloud(pcl::PointCloud<pcl::PointXYZI>::Ptr cloud, std::string dimensionToRemove, float stepSize1, float stepSize2) 
{ 
    pcl::PointXYZI cloudMin, cloudMax; 
    pcl::getMinMax3D(*cloud, cloudMin, cloudMax); 

    std::string dimen1, dimen2; 
    float dimen1Max, dimen1Min, dimen2Min, dimen2Max; 
    if (dimensionToRemove == "x") 
    { 
     dimen1 = "y"; 
     dimen2 = "z"; 
     dimen1Min = cloudMin.y; 
     dimen1Max = cloudMax.y; 
     dimen2Min = cloudMin.z; 
     dimen2Max = cloudMax.z; 
    } 
    else if (dimensionToRemove == "y") 
    { 
     dimen1 = "x"; 
     dimen2 = "z"; 
     dimen1Min = cloudMin.x; 
     dimen1Max = cloudMax.x; 
     dimen2Min = cloudMin.z; 
     dimen2Max = cloudMax.z; 
    } 
    else if (dimensionToRemove == "z") 
    { 
     dimen1 = "x"; 
     dimen2 = "y"; 
     dimen1Min = cloudMin.x; 
     dimen1Max = cloudMax.x; 
     dimen2Min = cloudMin.y; 
     dimen2Max = cloudMax.y; 
    } 

    std::vector<std::vector<int>> pointCountGrid; 
    int maxPoints = 0; 

    std::vector<upcloud> grid; 

    for (float i = dimen1Min; i < dimen1Max; i += stepSize1) 
    { 
     pcl::PointCloud<pcl::PointXYZI>::Ptr slice = upcl::passThroughFilter1D(cloud, dimen1, i, i + stepSize1); 
     grid.push_back(slice); 

     std::vector<int> slicePointCount; 

     for (float j = dimen2Min; j < dimen2Max; j += stepSize2) 
     { 
      pcl::PointCloud<pcl::PointXYZI>::Ptr grid_cell = upcl::passThroughFilter1D(slice, dimen2, j, j + stepSize2); 

      int gridSize = grid_cell->size(); 
      slicePointCount.push_back(gridSize); 

      if (gridSize > maxPoints) 
      { 
       maxPoints = gridSize; 
      } 
     } 
     pointCountGrid.push_back(slicePointCount); 
    } 

    cv::Mat mat(static_cast<int>(pointCountGrid.size()), static_cast<int>(pointCountGrid.at(0).size()), CV_8UC1); 
    mat = cv::Scalar(0); 

    for (int i = 0; i < mat.rows; ++i) 
    { 
     for (int j = 0; j < mat.cols; ++j) 
     { 
      int pointCount = pointCountGrid.at(i).at(j); 
      float percentOfMax = (pointCount + 0.0)/(maxPoints + 0.0); 
      int intensity = percentOfMax * 255; 

      mat.at<uchar>(i, j) = intensity; 
     } 
    } 

    return mat; 
}