當前位置: 首頁>>代碼示例>>C++>>正文


C++ Correspondences::end方法代碼示例

本文整理匯總了C++中pcl::Correspondences::end方法的典型用法代碼示例。如果您正苦於以下問題:C++ Correspondences::end方法的具體用法?C++ Correspondences::end怎麽用?C++ Correspondences::end使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pcl::Correspondences的用法示例。


在下文中一共展示了Correspondences::end方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: float

template <typename PointSource, typename PointTarget, typename NormalT, typename Scalar> int
pcl::registration::FPCSInitialAlignment <PointSource, PointTarget, NormalT, Scalar>::determineBaseMatches (
  const std::vector <int> &base_indices,
  std::vector <std::vector <int> > &matches,
  const pcl::Correspondences &pairs_a,
  const pcl::Correspondences &pairs_b,
  const float (&ratio)[2])
{
  // calculate edge lengths of base
  float dist_base[4];
  dist_base[0] = pcl::euclideanDistance (target_->points[base_indices[0]], target_->points[base_indices[2]]);
  dist_base[1] = pcl::euclideanDistance (target_->points[base_indices[0]], target_->points[base_indices[3]]);
  dist_base[2] = pcl::euclideanDistance (target_->points[base_indices[1]], target_->points[base_indices[2]]);
  dist_base[3] = pcl::euclideanDistance (target_->points[base_indices[1]], target_->points[base_indices[3]]);

  // loop over first point pair correspondences and store intermediate points 'e' in new point cloud
  PointCloudSourcePtr cloud_e (new PointCloudSource);
  cloud_e->resize (pairs_a.size () * 2);
  PointCloudSourceIterator it_pt = cloud_e->begin ();
  for (pcl::Correspondences::const_iterator it_pair = pairs_a.begin (), it_pair_e = pairs_a.end () ; it_pair != it_pair_e; it_pair++)
  {
    const PointSource *pt1 = &(input_->points[it_pair->index_match]);
    const PointSource *pt2 = &(input_->points[it_pair->index_query]);

    // calculate intermediate points using both ratios from base (r1,r2)
    for (int i = 0; i < 2; i++, it_pt++)
    {
      it_pt->x = pt1->x + ratio[i] * (pt2->x - pt1->x);
      it_pt->y = pt1->y + ratio[i] * (pt2->y - pt1->y);
      it_pt->z = pt1->z + ratio[i] * (pt2->z - pt1->z);
    }
  }

  // initialize new kd tree of intermediate points from first point pair correspondences
  KdTreeReciprocalPtr tree_e (new KdTreeReciprocal);
  tree_e->setInputCloud (cloud_e);

  std::vector <int> ids;
  std::vector <float> dists_sqr;

  // loop over second point pair correspondences
  for (pcl::Correspondences::const_iterator it_pair = pairs_b.begin (), it_pair_e = pairs_b.end () ; it_pair != it_pair_e; it_pair++)
  {
    const PointTarget *pt1 = &(input_->points[it_pair->index_match]);
    const PointTarget *pt2 = &(input_->points[it_pair->index_query]);

    // calculate intermediate points using both ratios from base (r1,r2)
    for (int i = 0; i < 2; i++)
    {
      PointTarget pt_e;
      pt_e.x = pt1->x + ratio[i] * (pt2->x - pt1->x);
      pt_e.y = pt1->y + ratio[i] * (pt2->y - pt1->y);
      pt_e.z = pt1->z + ratio[i] * (pt2->z - pt1->z);

      // search for corresponding intermediate points
      tree_e->radiusSearch (pt_e, coincidation_limit_, ids, dists_sqr);
      for (std::vector <int>::iterator it = ids.begin (), it_e = ids.end (); it != it_e; it++)
      {
        std::vector <int> match_indices (4);

        match_indices[0] = pairs_a[static_cast <int> (std::floor ((float)(*it/2.f)))].index_match;
        match_indices[1] = pairs_a[static_cast <int> (std::floor ((float)(*it/2.f)))].index_query;
        match_indices[2] = it_pair->index_match;
        match_indices[3] = it_pair->index_query;

        // EDITED: added coarse check of match based on edge length (due to rigid-body )
        if (checkBaseMatch (match_indices, dist_base) < 0)
          continue;

        matches.push_back (match_indices);
      }
    }
  }

  // return unsuccessfull if no match was found
  return (matches.size () > 0 ? 0 : -1);
}
開發者ID:butten,項目名稱:pcl,代碼行數:77,代碼來源:ia_fpcs.hpp


注:本文中的pcl::Correspondences::end方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。