if(voxel_size * std::numeric_limits<int>::max()<(voxel_max_bound - voxel_min_bound).maxCoeff()){utility::LogError("[VoxelDownSample] voxel_size is too small.");}
#pragmaomp parallel forschedule(static)\num_threads(utility::EstimateMaxThreads())for(int i =0; i <int(points_.size()); i++){std::vector<int> tmp_indices;std::vector<double> dist;size_t nb_neighbors = kdtree.SearchRadius(points_[i], search_radius,tmp_indices, dist);mask[i]=(nb_neighbors > nb_points);}
也可以封装起来使用更方便
template<typenamefunc_t>voidParallelFor(const Device& device,int64_t n,const func_t& func){if(device.GetType()!= Device::DeviceType::CPU){utility::LogError("ParallelFor for CPU cannot run on device {}.",device.ToString());}if(n ==0){return;}#pragmaomp parallel fornum_threads(utility::EstimateMaxThreads())for(int64_t i =0; i < n;++i){func(i);}}
classICPConvergenceCriteria{public:/// \brief Parameterized Constructor.////// \param relative_fitness If relative change (difference) of fitness score/// is lower than relative_fitness, the iteration stops. \param/// relative_rmse If relative change (difference) of inliner RMSE score is/// lower than relative_rmse, the iteration stops. \param max_iteration/// Maximum iteration before iteration stops.ICPConvergenceCriteria(double relative_fitness =1e-6,double relative_rmse =1e-6,int max_iteration =30):relative_fitness_(relative_fitness),relative_rmse_(relative_rmse),max_iteration_(max_iteration){}~ICPConvergenceCriteria(){}public:/// If relative change (difference) of fitness score is lower than/// `relative_fitness`, the iteration stops.double relative_fitness_;/// If relative change (difference) of inliner RMSE score is lower than/// `relative_rmse`, the iteration stops.double relative_rmse_;/// Maximum iteration before iteration stops.int max_iteration_;};auto result = pipelines::registration::RegistrationColoredICP(*source_down,*target_down,0.07, trans,pipelines::registration::TransformationEstimationForColoredICP(),pipelines::registration::ICPConvergenceCriteria(1e-6,1e-6,iterations[i]));