public static PointCloud GetRandomSample(PointCloud cloud, DistributedSamplingParameters samplingParams) { PointCloud sample = new PointCloud(); var indices = SelectPointIndices(cloud, samplingParams.NumberSamplePoints, samplingParams.MinimumAcceptableDistance); foreach (var i in indices) { sample.Points.Add((Point3D)cloud.Points[i].Clone()); } return(sample); }
internal PointCloud Process(PointCloud cloud, PointCloud prevCloud, Matrix bestGuessTransformation) { if (cloud.Points.Count < 4) { return(cloud); } var T_0 = (DenseMatrix)bestGuessTransformation; // sample point clouds PointCloud sampleScene; PointCloud model = prevCloud; if (this.UseSampling) { var samplingParams = new DistributedSamplingParameters( (int)(cloud.Points.Count * Registration.Settings.Default.SamplingProportion), Registration.Settings.Default.MinimumSamplingDistance); sampleScene = DistributedSampler.GetRandomSample(cloud, samplingParams); } else { sampleScene = cloud; } // run ICP on sampled data var T_opt = CalculateTransformation(sampleScene, model, T_0); // create deep clone of unoptimised cloud var optCloud = (PointCloud)cloud.Clone(); // apply T_opt to entire cloud and return for (int i = 0; i < optCloud.Points.Count; i++) { optCloud.Points[i].ApplyAffineTransformation(T_opt); } // return optimised cloud return(optCloud); }