天天看点

PCL - MLS代碼研讀(十二)- addProjectedPointNormal及copyMissingFields函數

PCL - MLS代碼研讀(十二)- addProjectedPointNormal及copyMissingFields函數

    • 前言
    • addProjectedPointNormal
    • copyMissingFields

前言

在PCL - MLS代碼研讀(十)- performProcessing函數和PCL - MLS代碼研讀(十一)- computeMLSPointNormal函數這兩篇文章中,時不時能看見到

addProjectedPointNormal

copyMissingFields

這兩個函數的蹤影。這兩個函數相較於之前介紹過的幾個函數較沒那麼重要,因此在這篇文章中一併介紹。

addProjectedPointNormal

addProjectedPointNormal

函數有

index

,

point

,

normal

,

curvature

四個入參,這個函數會將他們轉成合適的型別後,再新增到

projected_points

,

projected_points_normals

,

corresponding_input_indices

這三個數據結構中。

template <typename PointInT, typename PointOutT> void
pcl::MovingLeastSquares<PointInT, PointOutT>::addProjectedPointNormal (pcl::index_t index,
                                                                       const Eigen::Vector3d &point,
                                                                       const Eigen::Vector3d &normal,
                                                                       double curvature,
                                                                       PointCloudOut &projected_points,
                                                                       NormalCloud &projected_points_normals,
                                                                       PointIndices &corresponding_input_indices) const
{
           

輸入點

point

跟輸出點的類型可能不同,所以這裡建立一個新的:

然後把輸入點

point

裡的內容複製到

PointOutT

aux

裡面:

aux.x = static_cast<float> (point[0]);
  aux.y = static_cast<float> (point[1]);
  aux.z = static_cast<float> (point[2]);
           

如果有RGBA等欄位的話,就複製過去:

// Copy additional point information if available
  copyMissingFields ((*input_)[index], aux);
           

更新

projected_points

corresponding_input_indices.indices

// aux表示投影點
  // corresponding_input_indices要跟projected_points一起看,表示該投影點對應的輸入點的索引?
  projected_points.push_back (aux);
  corresponding_input_indices.indices.push_back (index);
           

如果

compute_normals_

為true,則複製法向量及曲率到

pcl::Normal

的點內,並更新

projected_points_normals

if (compute_normals_)
  {
    pcl::Normal aux_normal;
    aux_normal.normal_x = static_cast<float> (normal[0]);
    aux_normal.normal_y = static_cast<float> (normal[1]);
    aux_normal.normal_z = static_cast<float> (normal[2]);
    aux_normal.curvature = curvature;
    projected_points_normals.push_back (aux_normal);
  }
}
           

copyMissingFields

如果

point_in

RGBA

欄位,則將他們複製到

point_out

中。

template <typename PointInT, typename PointOutT> void
pcl::MovingLeastSquares<PointInT, PointOutT>::copyMissingFields (const PointInT &point_in,
                                                                 PointOutT &point_out) const
{
  PointOutT temp = point_out;
  copyPoint (point_in, point_out);
  point_out.x = temp.x;
  point_out.y = temp.y;
  point_out.z = temp.z;
}
           

继续阅读