Beispiel #1
0
        public void ScannerPerson_V_Rotate()
        {
            this.pointCloudTarget = new PointCloud(pathUnitTests + "\\1.obj");
            //PointCloud.ResizeVerticesTo1(pointCloudTarget);

            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);
            //Vertices.TranslateVertices(pointCloudTarget, 0, -300, 0);
            PointCloud.RotateDegrees(pointCloudSource, 25, 10, 25);


            this.pointCloudResult = pca.AlignPointClouds_OneVector(this.pointCloudSource, this.pointCloudTarget, 0, 0);

            this.pointCloudSource = PointCloud.CloneAll(pointCloudResult);
            this.pointCloudResult = pca.AlignPointClouds_OneVector(this.pointCloudResult, this.pointCloudTarget, 1, 1);

            this.pointCloudSource = PointCloud.CloneAll(pointCloudResult);
            this.pointCloudResult = pca.AlignPointClouds_OneVector(this.pointCloudResult, this.pointCloudTarget, 2, 2);

            this.pointCloudSource = PointCloud.CloneAll(pointCloudResult);
            this.pointCloudResult = pca.AlignPointClouds_OneVector(this.pointCloudResult, this.pointCloudTarget, 0, 0);


            //this.pointCloudSource = Vertices.CopyVertices(pointCloudResult);
            //this.pointCloudResult = pca.AlignPointClouds_OneVector(this.pointCloudResult, this.pointCloudTarget, 1, 1);


            // this.pointCloudResult = pca.AlignPointClouds_OneVector(this.pointCloudResult, this.pointCloudTarget, 0, 0);

            //this.pointCloudResult = pca.AlignPointClouds_OneVector(pointCloudResult, this.pointCloudTarget, 1, 2);

            //pointCloudResult = null;

            CheckResultTargetAndShow_Cloud(this.threshold);
        }
Beispiel #2
0
        public void Simple3Vectors()
        {
            this.pointCloudTarget = new PointCloud();

            pointCloudTarget.AddVector(new Vector3(1, 0, 0));
            pointCloudTarget.AddVector(new Vector3(0, 1, 0));
            pointCloudTarget.AddVector(new Vector3(1, 1, 0));


            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);
            PointCloud.Translate(pointCloudSource, 1, 4, 5);


            this.pointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(pointCloudSource, pointCloudTarget);
            float f = IterativeClosestPointTransform.Instance.MeanDistance;

            Assert.IsTrue(f < this.threshold);

            //if (pointCloudResult != null)
            //{
            //    for (int i = 0; i < 3; i++)
            //    {

            //        System.Diagnostics.Debug.WriteLine("target: " + pointCloudTarget[i].ToString() + " : result: " + pointCloudResult[i].ToString());

            //    }
            //}
        }
Beispiel #3
0
        public static float Test6_Bunny_PCA(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            mypointCloudTarget = new PointCloud(path + "\\bunny.obj");

            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);



            Matrix3 R = new Matrix3();

            //ICP converges with a rotation of
            //R = R.RotationXYZ(60, 60, 60);
            R = R.RotationXYZDegrees(124, 124, 124);


            PointCloud.Rotate(mypointCloudSource, R);
            PCA pca = new PCA();

            mypointCloudResult = pca.AlignPointClouds_SVD(mypointCloudSource, mypointCloudTarget);
            if (pca.MeanDistance > 1e-5)
            {
                mypointCloudResult = pca.AlignPointClouds_SVD(mypointCloudResult, mypointCloudTarget);
            }

            //mypointCloudResult = pca.AlignPointClouds_SVD(mypointCloudResult, mypointCloudTarget);

            //mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudResult, mypointCloudTarget);

            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #4
0
        /// <summary>
        /// calculates a start solution set in total of "myNumberPoints" points
        /// </summary>
        /// <param name="pointsTargetSubset"></param>
        /// <param name="pointsSourceSubset"></param>
        /// <returns></returns>
        private static ICPSolution CalculateStartSolution(ref PointCloud pointsSourceSubset, ref PointCloud pointsTargetSubset, int myNumberPoints,
                                                          LandmarkTransform myLandmarkTranform, PointCloud pointsTarget, PointCloud pointsSource, int maxNumberOfIterations)
        {
            try
            {
                if (CheckSourceTarget(pointsTarget, pointsSource))
                {
                    return(null);
                }
                pointsTargetSubset = PointCloud.CloneAll(pointsTarget);
                pointsSourceSubset = PointCloud.CloneAll(pointsSource);

                ICPSolution res = IterateStartPoints(pointsSourceSubset, pointsTargetSubset, myNumberPoints, myLandmarkTranform, maxNumberOfIterations);
                if (res == null)
                {
                    System.Windows.Forms.MessageBox.Show("Could not find starting points for ICP Iteration - bad matching");
                    return(null);
                }
                PointCloud.RemoveEntriesByIndices(ref pointsSourceSubset, ref pointsTargetSubset, res.RandomIndices);

                return(res);
            }
            catch (Exception err)
            {
                System.Windows.Forms.MessageBox.Show("Error in CalculateStartSolution of ICP: " + err.Message);
                return(null);
            }
        }
Beispiel #5
0
        public static float Test7_Face_KnownTransformation_PCA_55000(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "PointClouds\\UnitTests";

            mypointCloudTarget = new PointCloud(path + "\\KinectFace_1_55000.obj");


            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);


            PointCloud.ScaleByFactor(mypointCloudSource, 0.9f);
            Matrix3 R = new Matrix3();

            R = R.RotationXYZDegrees(60, 60, 60);
            PointCloud.Rotate(mypointCloudSource, R);
            PointCloud.Translate(mypointCloudSource, 0.3f, 0.5f, -0.4f);

            PCA pca = new PCA();

            mypointCloudResult = pca.AlignPointClouds_SVD(mypointCloudSource, mypointCloudTarget);
            mypointCloudSource = mypointCloudResult;

            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #6
0
        public void ScannerPerson_V_SVD_Rotate()
        {
            this.pointCloudTarget = new PointCloud(pathUnitTests + "\\1.obj");

            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);
            //Vertices.TranslateVertices(pointCloudTarget, 0, -300, 0);
            PointCloud.RotateDegrees(pointCloudSource, 25, 10, 25);
            //Vertices.Rotate(pointCloudSource, 25, 90, 25);

            this.pointCloudResult = pca.AlignPointClouds_OneVector(this.pointCloudSource, this.pointCloudTarget, 0, 0);
            this.pointCloudSource = PointCloud.CloneAll(pointCloudResult);

            this.pointCloudResult = pca.AlignPointClouds_SVD(this.pointCloudSource, this.pointCloudTarget);

            // this.pointCloudResult = pca.AlignPointClouds_OneVector(this.pointCloudResult, this.pointCloudTarget, 0, 0);

            //this.pointCloudResult = pca.AlignPointClouds_OneVector(pointCloudResult, this.pointCloudTarget, 1, 2);

            //pointCloudResult = null;


            ShowPointCloudsInWindow_PCAVectors(true);

            Assert.IsTrue(this.threshold > pca.MeanDistance);
        }
Beispiel #7
0
        protected void CreateCuboid(int numberOfPoints)
        {
            pointCloudTarget = ExamplePointClouds.Cuboid(4, 2, 1, numberOfPoints, numberOfPoints, numberOfPoints);
            pointCloudSource = PointCloud.CloneAll(pointCloudTarget);

            pointCloudSource = PointCloud.ResizeAndSort_Distance(pointCloudSource);
            pointCloudTarget = PointCloud.ResizeAndSort_Distance(pointCloudTarget);
        }
Beispiel #8
0
        protected void CreateCube(int numberOfPoints)
        {
            List <Vector3> listVectors = ExamplePointClouds.Cuboid_Corners_CenteredAt0(1, 2, 1);

            this.pointCloudTarget = PointCloud.FromListVector3(listVectors);


            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);
        }
Beispiel #9
0
        public static float Test5_Cube8Shuffle_1Milion(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult, float cubeSize)
        {
            mypointCloudTarget = ExamplePointClouds.Cube_RegularGrid_Empty(cubeSize, 409);
            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);

            PointCloud.ShuffleRandom(mypointCloudSource);

            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #10
0
        public static float Test5_Cube8Shuffle(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult, float cubeSize)
        {
            mypointCloudTarget = PointCloud.CreateCube_Corners_CenteredAt0(cubeSize);
            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);

            PointCloud.ShuffleTest(mypointCloudSource);

            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #11
0
        public static float Test2_Identity(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            //mypointCloudTarget = Vertices.CreateSomePoints();
            mypointCloudTarget = PointCloud.CreateCube_Corners_CenteredAt0(50);
            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);


            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #12
0
        public static float Test1_Translation(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            mypointCloudTarget = PointCloud.CreateSomePoints();
            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);
            PointCloud.Translate(mypointCloudSource, 10, 3, 8);


            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #13
0
        public static float Test5_CubeScale_Inhomogenous(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            mypointCloudTarget = PointCloud.CreateCube_Corners_CenteredAt0(50);

            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);
            PointCloud.ScaleByVector(mypointCloudSource, new Vector3(1, 2, 3));

            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
 public void TranslateCuboid()
 {
     this.pointCloudSource = PointCloud.CreateCuboid(5, 8, 60);
     pointCloudResult      = PointCloud.CloneAll(pointCloudSource);
     PointCloud.Translate(pointCloudResult, 30, -20, 12);
     ShowVerticesInWindow(new byte[4] {
         255, 255, 255, 255
     }, new byte[4] {
         255, 0, 0, 255
     });
 }
Beispiel #15
0
        public void Rotate()
        {
            this.pointCloudTarget = new PointCloud(pathUnitTests + "\\1.obj");

            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);
            PointCloud.RotateDegrees(pointCloudSource, 25, 10, 25);

            this.pointCloudResult = pca.AlignPointClouds_SVD(this.pointCloudSource, this.pointCloudTarget);

            CheckResultTargetAndShow_Cloud(this.threshold);
        }
Beispiel #16
0
        public static float Test8_CubeOutliers_Translate(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            mypointCloudTarget = PointCloud.CreateCube_Corners_CenteredAt0(20);
            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);
            PointCloud.Translate(mypointCloudSource, 0, -300, 0);
            PointCloud.CreateOutliers(mypointCloudSource, 5);


            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #17
0
        public void Rotate()
        {
            CreateCube();
            //pointCloudTarget.ResizeVerticesTo1();
            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);

            PointCloud.RotateDegrees(pointCloudSource, 45, 0, 0);

            this.pointCloudResult = pca.AlignPointClouds_SVD(pointCloudSource, pointCloudTarget);

            CheckResultTargetAndShow_Cube();
        }
Beispiel #18
0
        public static float Test3_Scale(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            //mypointCloudTarget = CreateSomePoints();
            mypointCloudTarget = PointCloud.CreateCube_Corners_CenteredAt0(50);

            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);

            PointCloud.ScaleByFactor(mypointCloudSource, 0.2f);

            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #19
0
        public static float Test11_Person(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            mypointCloudTarget = new PointCloud(path + "\\1.obj");

            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);
            PointCloud.RotateDegrees(mypointCloudSource, 25, 10, 25);



            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
        public void ScaleCuboid()
        {
            this.pointCloudSource = PointCloud.CreateCuboid(5, 8, 60);
            pointCloudResult      = PointCloud.CloneAll(pointCloudSource);

            PointCloud.ScaleByVector(pointCloudResult, new Vector3(1, 2, 3));
            ShowVerticesInWindow(new byte[4] {
                255, 255, 255, 255
            }, new byte[4] {
                255, 0, 0, 255
            });
        }
Beispiel #21
0
        public void Cube_NotWorking()
        {
            this.pointCloudTarget = PointCloud.CreateCube_RegularGrid_Empty(cubeSizeX, 1);
            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);

            PointCloud.RotateDegrees(pointCloudSource, 45, 45, 45);


            this.pointCloudResult = pca.AlignPointClouds_SVD(this.pointCloudSource, this.pointCloudTarget);


            this.ShowResultsInWindow_Cube(true);
        }
Beispiel #22
0
        public static float Test5_CubeRotate45(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult, float cubeSize)
        {
            mypointCloudTarget = PointCloud.CreateCube_RandomPointsOnPlanes(cubeSize, 10);

            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);

            Matrix3 R = CreateAndPrintMatrix(45, 45, 45);

            PointCloud.Rotate(mypointCloudSource, R);

            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #23
0
        public void Rotate()
        {
            this.pointCloudTarget = new PointCloud(pathUnitTests + "\\KinectFace_1_15000.obj");

            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);
            PointCloud.RotateDegrees(pointCloudSource, 25, 90, 25);


            this.pointCloudResult = pca.AlignPointClouds_SVD(this.pointCloudSource, this.pointCloudTarget);
            double executionTime = Performance_Stop("Execution Time");//on i3_2121 (3.3 GHz)

            Assert.IsTrue(executionTime < 3);
            CheckResultTargetAndShow_Cloud(this.threshold);
        }
Beispiel #24
0
        public static float Test5_CubeRotate(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            mypointCloudTarget = PointCloud.CreateCube_Corners_CenteredAt0(50);

            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);

            Matrix3 R = new Matrix3();

            R = R.RotationXYZDegrees(90, 124, -274);
            PointCloud.Rotate(mypointCloudSource, R);

            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #25
0
        public static float Test2_RotationX30Degrees(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult)
        {
            //mypointCloudTarget = Vertices.CreateSomePoints();
            mypointCloudTarget = PointCloud.CreateCube_Corners_CenteredAt0(50);
            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);

            Matrix3 R = Matrix3.CreateRotationX(30);

            PointCloud.Rotate(mypointCloudSource, R);


            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #26
0
        public void Cube_ProjectedPoints()
        {
            this.pointCloudSource    = PointCloud.CreateCube_RegularGrid_Empty(cubeSizeX, 1);
            this.pointCloudAddition1 = PointCloud.CloneAll(pointCloudSource);

            pca.PCA_OfPointCloud(pointCloudSource);

            this.pointCloudSource = PointCloud.FromListVector3(pca.PointsResult0);
            this.pointCloudTarget = PointCloud.FromListVector3(pca.PointsResult1);
            this.pointCloudResult = PointCloud.FromListVector3(pca.PointsResult2);

            this.ShowResultsInWindow_Cube_ProjectedPoints(true);

            //Show4PointCloudsInWindow(true);
        }
Beispiel #27
0
        public static float Test10_CubeRTranslate(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult, float cubeSize)
        {
            mypointCloudTarget = ExamplePointClouds.Cube_RegularGrid_Empty(cubeSize, 5);
            //mypointCloudTarget = Vertices.CreateCube_Corners(10);

            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);


            PointCloud.Translate(mypointCloudSource, cubeSize * 1.2f, -cubeSize * 2.5f, cubeSize * 2);



            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #28
0
        public static float Test10_Cube26p_RotateShuffle(ref PointCloud mypointCloudTarget, ref PointCloud mypointCloudSource, ref PointCloud mypointCloudResult, float cubeSize)
        {
            mypointCloudTarget = ExamplePointClouds.Cube_RegularGrid_Empty(cubeSize, 2);
            mypointCloudSource = PointCloud.CloneAll(mypointCloudTarget);

            Matrix3 R = CreateAndPrintMatrix(65, -123, 35);

            PointCloud.Rotate(mypointCloudSource, R);

            PointCloud.ShuffleRandom(mypointCloudSource);


            mypointCloudResult = IterativeClosestPointTransform.Instance.PerformICP(mypointCloudSource, mypointCloudTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Beispiel #29
0
        public void V_RotateNotWorking()
        {
            this.pointCloudTarget = new PointCloud(pathUnitTests + "\\KinectFace_1_15000.obj");
            //PointCloud.ResizeVerticesTo1(pointCloudTarget);

            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);
            PointCloud.RotateDegrees(pointCloudSource, 60, 60, 90);


            this.pointCloudResult = pca.AlignPointClouds_OneVector(this.pointCloudSource, this.pointCloudTarget, 0, 0);


            ShowPointCloudsInWindow_PCAVectors(true);

            Assert.IsTrue(this.threshold > pca.MeanDistance);
        }
Beispiel #30
0
        public void Rotate_Custom()
        {
            this.pointCloudTarget = new PointCloud(pathUnitTests + "\\bunny.obj");

            this.pointCloudSource = PointCloud.CloneAll(pointCloudTarget);

            PointCloud.RotateDegrees(pointCloudSource, 124, 124, 124);


            this.pointCloudResult = pca.AlignPointClouds_SVD(this.pointCloudSource, this.pointCloudTarget);

            CheckResultTargetAndShow_Cloud(this.threshold);
            double executionTime = Performance_Stop("PCA_Bunny_Rotate");//5 seconds on i3_2121 (3.3 GHz)

            Assert.IsTrue(executionTime < 5);
        }