这篇教程C++ tree函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tree函数的典型用法代码示例。如果您正苦于以下问题:C++ tree函数的具体用法?C++ tree怎么用?C++ tree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tree函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: pointsWithNormalSourceint PointCloudStitching::stitch(pcl::PointCloud<PointT>& points, double epsilon, double maxCorrespondanceDistance){ if (this->stitching.size() == 0) { pcl::copyPointCloud(points, this->stitching); return 0; } // Compute surface normals and curvature pcl::PointCloud<PointT> tempTarget; pcl::copyPointCloud(this->stitching, tempTarget); pcl::PointCloud<pcl::PointNormal>::Ptr pointsWithNormalSource (new pcl::PointCloud<pcl::PointNormal>); pcl::PointCloud<pcl::PointNormal>::Ptr pointsWithNormalTarget (new pcl::PointCloud<pcl::PointNormal>); pcl::NormalEstimation<PointT, pcl::PointNormal> normalEstimate; pcl::search::KdTree<PointT>::Ptr tree (new pcl::search::KdTree<PointT> ()); normalEstimate.setSearchMethod(tree); normalEstimate.setKSearch(30); normalEstimate.setInputCloud(points.makeShared()); normalEstimate.compute(*pointsWithNormalSource); pcl::copyPointCloud(points, *pointsWithNormalSource); normalEstimate.setInputCloud (tempTarget.makeShared()); normalEstimate.compute(*pointsWithNormalTarget); pcl::copyPointCloud (tempTarget, *pointsWithNormalTarget); // Instantiate custom point representation MyPointNormal pointNormal; // ... and weight the 'curvature' dimension so that it is balanced against x, y, and z float alpha[4] = {1.0, 1.0, 1.0, 1.0}; pointNormal.setRescaleValues(alpha); // Align pcl::IterativeClosestPointNonLinear<pcl::PointNormal, pcl::PointNormal> registration; registration.setTransformationEpsilon(epsilon); // Set the maximum distance between two correspondences registration.setMaxCorrespondenceDistance(maxCorrespondanceDistance); // Set the point representation registration.setPointRepresentation (boost::make_shared<const MyPointNormal> (pointNormal)); registration.setInputSource(pointsWithNormalSource); registration.setInputTarget(pointsWithNormalTarget); registration.setMaximumIterations(30); PCL_ERROR("Source size: %d -- Target size: %d/n", (int)pointsWithNormalSource.get()->size(), (int)pointsWithNormalTarget.get()->size()); Eigen::Matrix4f tf = Eigen::Matrix4f::Identity(); pcl::PointCloud<pcl::PointNormal>::Ptr regResult = pointsWithNormalSource; PCL_ERROR("Stitching ... "); registration.align(*regResult); PCL_ERROR("Done!/n"); tf = registration.getFinalTransformation().inverse();// PCL_ERROR("/nTransform:/n");// PCL_ERROR("| %f %f %f %f |/n", tf(0,0), tf(0,1), tf (0,2), tf(0,3));// PCL_ERROR("| %f %f %f %f |/n", tf(1,0), tf(1,1), tf (1,2), tf(1,3));// PCL_ERROR("| %f %f %f %f |/n", tf(2,0), tf(2,1), tf (2,2), tf(2,3));// PCL_ERROR("| %f %f %f %f |/n/n", tf(3,0), tf(3,1), tf (3,2), tf(3,3)); pcl::transformPointCloud(*pointsWithNormalSource, *regResult, tf); *regResult += *pointsWithNormalTarget; pcl::copyPointCloud(*regResult, this->stitching); return 0;}
开发者ID:RobTek8Grp,项目名称:RoVi,代码行数:70,
示例2: scale_of_anisotropy unsigned int scale_of_anisotropy (const Point_set& points, double& size) { Tree tree(points.begin(), points.end()); double ratio_kept = (points.size() < 1000) ? 1. : 1000. / (points.size()); std::vector<Point> subset; for (std::size_t i = 0; i < points.size (); ++ i) if (rand() / (double)RAND_MAX < ratio_kept) subset.push_back (points[i]); std::vector<unsigned int> scales; generate_scales (std::back_inserter (scales)); std::vector<unsigned int> chosen; for (std::size_t i = 0; i < subset.size (); ++ i) { Neighbor_search search(tree, subset[i],scales.back()); double current = 0.; unsigned int nb = 0; std::size_t index = 0; double maximum = 0.; unsigned int c = 0; for (Search_iterator search_iterator = search.begin(); search_iterator != search.end (); ++ search_iterator, ++ nb) { current += search_iterator->second; if (nb + 1 == scales[index]) { double score = std::sqrt (current / scales[index]) / std::pow (scales[index], 0.75); // NB ^ (3/4) if (score > maximum) { maximum = score; c = scales[index]; } ++ index; if (index == scales.size ()) break; } } chosen.push_back (c); } double mean = 0.; for (std::size_t i = 0; i < chosen.size(); ++ i) mean += chosen[i]; mean /= chosen.size(); unsigned int aniso_scale = static_cast<unsigned int>(mean); size = 0.; for (std::size_t i = 0; i < subset.size (); ++ i) { Neighbor_search search(tree, subset[i], aniso_scale); size += std::sqrt ((-- search.end())->second); } size /= subset.size(); return aniso_scale; }
开发者ID:GilesBathgate,项目名称:cgal,代码行数:66,
|