Пример #1
0
        public PointCloud AlignPointClouds_SVD_WithShuflleEffect(bool axesRotateEffect, PointCloud pointCloudSource, PointCloud pointCloudTarget)
        {
            try
            {
                if (pointCloudSource == null || pointCloudTarget == null || pointCloudSource.Count == 0 || pointCloudTarget.Count == 0)
                {
                    System.Diagnostics.Debug.WriteLine("PCA - please check point clouds ");
                    return(null);
                }
                this.Matrix      = Matrix4.Identity;
                pcSourceCentered = CalculatePCA_Internal(pointCloudSource);
                PrepareTargetTree(pointCloudTarget);


                PointCloud myPointCloudIteration = PointCloud.CloneAll(pointCloudSource);

                for (int i = 0; i < MaxmimumIterations; i++)
                {
                    float meanDistance = SVD_Iteration(myPointCloudIteration);
                    System.Diagnostics.Debug.WriteLine("-->>  Iteration " + i.ToString() + " : Mean Distance : " + meanDistance.ToString("G") + ": duration: " + GlobalVariables.TimeSpanString());

                    if (meanDistance < ThresholdConvergence)
                    {
                        break;
                    }
                    myPointCloudIteration = pcResultBest;
                }

                //final check:

                pcResultCentered = CalculatePCA_Internal(pcResult);


                //"Shuffle" effect - the target points are in other order after kdtree search:
                //The mean distance calculated again, as check (was calculated before in the kdTree routine)

                MeanDistance = PointCloud.MeanDistance(pcResultBest, pcTreeResult);
                System.Diagnostics.Debug.WriteLine("-->>  TO CHECK: PCA (SVD) - Final Mean Distance : " + MeanDistance.ToString("G"));

                //MeanDistance = PointCloud.MeanDistance(pointCloudResult, pointCloudTarget);
                //System.Diagnostics.Debug.WriteLine("-->>  PCA (SVD) - Final Mean Distance : " + MeanDistance.ToString("G"));

                this.Matrix      = AdjustSourceTargetByTranslation(Matrix, pointCloudSource, pointCloudTarget);
                pcResult         = Matrix.TransformPoints(pointCloudSource);
                pcResultCentered = CalculatePCA_Internal(pcResult);

                //MeanDistance = PointCloud.MeanDistance(pointCloudResult, pointCloudTarget);
                //System.Diagnostics.Debug.WriteLine("-->>  PCA (SVD) - Final Mean Distance : " + MeanDistance.ToString("G"));

                //for display later:
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Error aligning point cloud");
            }
            return(pcResult);
        }
Пример #2
0
 public static void ShowLastTimeSpan(string name)
 {
     System.Diagnostics.Debug.WriteLine("--Duration for " + name + " : " + GlobalVariables.TimeSpanString());
 }