public void Test_CorrespondenceList_Constructor()
        {
            CorrespondenceCollection actual   = new CorrespondenceCollection(correspondenceList);
            CorrespondenceCollection expected = correspondences;

            Assert.AreEqual(expected, actual);
        }
            public ICPPreparationStepCompletedMessage(CorrespondenceCollection correspondences, Transform transform, int iterationIndex)
            {
                this.Correspondences = correspondences;
                this.Transform       = transform;

                this.IterationIndex = iterationIndex;
            }
            private float ComputeErrorAfterTransform(CorrespondenceCollection correspondences,
                                                     Transform originalTransform, Transform currentTransform,
                                                     AggregationMethods.AggregationMethod aggregationMethod)
            {
                //Apply the newTransform to the model points
                List <Point> modelPoints = TransformPoints(correspondences.ModelPoints, originalTransform, currentTransform);

                //Normalize the points if required
                Matrix4x4 normalizationMatrix = Matrix4x4.identity;

                if (configuration.NormalizePoints)
                {
                    normalizationMatrix = new PointNormalizer().ComputeNormalizationMatrix(modelPoints, correspondences.StaticPoints);
                }

                //Compute the correspondence errors
                List <float> errors = ComputeCorrespondenceErrors(
                    normalizationMatrix,
                    modelPoints: modelPoints,
                    staticPoints: correspondences.StaticPoints
                    );

                //Always use the mean of the errors for the termination error to
                // ensure that the number of correspondences does not influence the error
                float error = aggregationMethod(errors);

                return(error);
            }
        public void Test_ComputeError_WithNormalization()
        {
            CorrespondenceCollection correspondences = new CorrespondenceCollection();

            correspondences.Add(new Correspondence(
                                    staticPoint: new Point(new Vector3(1, 2, 3)),
                                    modelPoint: new Point(new Vector3(2, 4, 4))
                                    ));
            correspondences.Add(new Correspondence(
                                    staticPoint: new Point(new Vector3(2, 3, 4)),
                                    modelPoint: new Point(new Vector3(4, 4, 3))
                                    ));

            errorMetric = new ErrorMetric(
                new ErrorMetric.Configuration(
                    distanceMetric: DistanceMetrics.SquaredEuclidean,
                    aggregationMethod: AggregationMethods.Sum,
                    normalizePoints: true
                    )
                );

            float expected = 1.3333333333f;
            float actual   = errorMetric.ComputeError(correspondences, null, null);

            Assert.That(actual, Is.EqualTo(expected).Within(tolerance));
        }
 public float ComputeTerminationError(CorrespondenceCollection correspondences, Transform originalTransform, Transform currentTransform)
 {
     //Always use the mean of the errors for the termination error to
     //ensure that the number of correspondences does not influence the error
     return(ComputeErrorAfterTransform(correspondences,
                                       originalTransform, currentTransform,
                                       AggregationMethods.Mean));
 }
        public void Test_Equals_AreEqual()
        {
            CorrespondenceCollection actual = correspondences;
            CorrespondenceCollection other  = new CorrespondenceCollection(modelPointList, staticPointList, correspondenceList);

            Assert.IsTrue(actual.Equals(other));
            Assert.IsTrue(other.Equals(actual));
            Assert.AreEqual(actual.GetHashCode(), other.GetHashCode());
        }
        public void Test_ComputeError_EmptyCorrespondences()
        {
            CorrespondenceCollection correspondences = new CorrespondenceCollection();

            float expected = 0.0f;
            float actual   = errorMetric.ComputeError(correspondences, null, null);

            Assert.That(actual, Is.EqualTo(expected).Within(tolerance));
        }
        public void Constructor_NoDuplicates()
        {
            List <Correspondence> argument = correspondenceList;

            CorrespondenceCollection expected = new CorrespondenceCollection(correspondenceList);

            CorrespondenceCollection actual = new CorrespondenceCollection(argument);

            Assert.AreEqual(expected, actual);
        }
        public void Test_CorrespondenceModelStaticPoints_Constructor()
        {
            CorrespondenceCollection actual = new CorrespondenceCollection(
                modelpoints: modelPointList,
                staticpoints: staticPointList
                );
            CorrespondenceCollection expected = correspondences;

            Assert.AreEqual(expected, actual);
        }
        public void Test_CollectTrueCorrespondences(string file, CorrespondenceCollection expected)
        {
            _TransformationComputer computer = new _TransformationComputer(InputPath(file));

            computer.ReadObjFile();
            computer.CollectCorrespondences();

            CorrespondenceCollection actual = computer.Correspondences;

            Assert.AreEqual(expected, actual);
        }
        public void FindTransformTest(CorrespondenceCollection correspondences, Matrix4x4 expected)
        {
            Matrix4x4 actual = transformFinder.FindTransform(correspondences);

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    Assert.That(actual[i, j], Is.EqualTo(expected[i, j]).Within(precision));
                }
            }
        }
        public void Constructor_FewDuplicates()
        {
            List <Correspondence> input = new List <Correspondence> {
                this.correspondenceList[0],
                this.correspondenceList[1],
                this.correspondenceList[1],
                this.correspondenceList[1],
                this.correspondenceList[2],
                this.correspondenceList[3]
            };
            CorrespondenceCollection expected = new CorrespondenceCollection(correspondenceList);

            CorrespondenceCollection actual = new CorrespondenceCollection(input);

            Assert.AreEqual(expected, actual);
        }
        public void Test_Equals_AreNotEqual()
        {
            CorrespondenceCollection actual = correspondences;

            Point modelPoint  = Auxilaries.RandomPoint();
            Point staticPoint = Auxilaries.RandomPoint();

            modelPointList.Add(modelPoint);
            staticPointList.Add(staticPoint);
            correspondences.Add(new Correspondence(modelPoint: modelPoint, staticPoint: staticPoint));
            CorrespondenceCollection other = new CorrespondenceCollection(modelPointList, staticPointList, correspondenceList);

            Assert.IsFalse(actual.Equals(other));
            Assert.IsFalse(other.Equals(actual));
            Assert.AreNotEqual(actual.GetHashCode(), other.GetHashCode());
        }
        public void TestFindCorrespondencesStaticEqualsModel()
        {
            ReadOnlyCollection <Point> staticPoints = cubeLeft.AsReadOnly();

            ReadOnlyCollection <Point> modelPoints = cubeLeft.AsReadOnly();

            CorrespondenceCollection expected = new CorrespondenceCollection(
                new List <Correspondence> {
                new Correspondence(
                    cubeLeft[0],
                    cubeLeft[0]
                    ),
                new Correspondence(
                    cubeLeft[1],
                    cubeLeft[1]
                    ),
                new Correspondence(
                    cubeLeft[2],
                    cubeLeft[2]
                    ),
                new Correspondence(
                    cubeLeft[3],
                    cubeLeft[3]
                    ),
                new Correspondence(
                    cubeLeft[4],
                    cubeLeft[4]
                    ),
                new Correspondence(
                    cubeLeft[5],
                    cubeLeft[5]
                    ),
                new Correspondence(
                    cubeLeft[6],
                    cubeLeft[6]
                    ),
                new Correspondence(
                    cubeLeft[7],
                    cubeLeft[7]
                    )
            }
                );
            CorrespondenceCollection actual = new NearstPointCorrespondenceFinder(new AllPointsSampler(configuration)).Find(staticPoints, modelPoints);

            Assert.That(actual, Is.EquivalentTo(expected));
        }
Example #15
0
        public float ComputeInitialError(CorrespondenceCollection correspondences)
        {
            bool    xi;
            float   error = 0;
            Vector3 modelPoint;

            for (int i = 0; i < correspondences.Count; i++)
            {
                modelPoint = correspondences.ModelPoints[i].Position;
                xi         = staticModelContainmentDetector.GameObjectContains(modelPoint);
                error     += ComputeError(
                    modelPoint: modelPoint,
                    staticPoint: correspondences[i].StaticPoint.Position,
                    xi: xi ? 1 : 0
                    );
            }
            return(error / (correspondences.Count));
        }
        public void Test_NeutralTransform()
        {
            CorrespondenceCollection correspondences = new CorrespondenceCollection(
                modelpoints: modelPoints,
                staticpoints: modelPoints
                );
            Matrix4x4 expected = Matrix4x4.identity;

            Matrix4x4 actual = TransformFinder.FindTransform(correspondences);

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    Assert.That(actual[i, j], Is.EqualTo(expected[i, j]).Within(precision));
                }
            }
        }
Example #17
0
            public float ComputeInitialError(CorrespondenceCollection correspondences)
            {
                Matrix4x4 normalizationMatrix = Matrix4x4.identity;

                if (configuration.NormalizePoints)
                {
                    normalizationMatrix = new PointNormalizer().ComputeNormalizationMatrix(correspondences.ModelPoints, correspondences.StaticPoints);
                }

                List <float> errors = ComputeCorrespondenceErrors(
                    normalizationMatrix,
                    modelPoints: correspondences.ModelPoints,
                    staticPoints: correspondences.StaticPoints
                    );

                //Aggregate the errors, use mean to ensure that the number of correspondences does not influence the error
                float error = AggregationMethods.Mean(errors);

                return(error);
            }
Example #18
0
        private float ComputeErrorSumAfterTransform(CorrespondenceCollection correspondences, Transform originalTransform, Transform currentTransform)
        {
            //Apply the newTransform to the model points
            List <Point> modelPoints = TransformPoints(correspondences.ModelPoints, originalTransform, currentTransform);

            bool xi;

            float error = 0;

            for (int i = 0; i < modelPoints.Count; i++)
            {
                xi     = staticModelContainmentDetector.GameObjectContains(currentTransform.TransformPoint(modelPoints[i].Position));
                error += ComputeError(
                    modelPoint: modelPoints[i].Position,
                    staticPoint: correspondences[i].StaticPoint.Position,
                    xi: xi ? 1 : 0
                    );
            }
            return(error);
        }
        public void Init()
        {
            modelPointList     = new List <Point>();
            staticPointList    = new List <Point>();
            correspondenceList = new List <Correspondence>
            {
                Auxilaries.RandomCorrespondence(),
                    Auxilaries.RandomCorrespondence(),
                    Auxilaries.RandomCorrespondence(),
                    Auxilaries.RandomCorrespondence()
            };

            correspondences = new CorrespondenceCollection();
            foreach (Correspondence correspondence in correspondenceList)
            {
                correspondences.Add(correspondence);

                modelPointList.Add(correspondence.ModelPoint);
                staticPointList.Add(correspondence.StaticPoint);
            }
        }
        public void Test_Add_Correspondence()
        {
            Correspondence correspondence = Auxilaries.RandomCorrespondence();

            CorrespondenceCollection actual = new CorrespondenceCollection();

            actual.Add(correspondence);

            List <Correspondence> expected_correspondences = new List <Correspondence> {
                correspondence
            };
            List <Point> expected_modelpoints = new List <Point> {
                correspondence.ModelPoint
            };
            List <Point> expected_staticpoints = new List <Point> {
                correspondence.StaticPoint
            };

            Assert.That(actual.Correspondences, Is.EquivalentTo(expected_correspondences));
            Assert.That(actual.ModelPoints, Is.EquivalentTo(expected_modelpoints));
            Assert.That(actual.StaticPoints, Is.EquivalentTo(expected_staticpoints));
        }
        public void Test_Add_DistanceNode()
        {
            Point staticPoint = Auxilaries.RandomPoint();
            Point modelPoint  = Auxilaries.RandomPoint();
            float distance    = 3;

            DistanceNode node = new DistanceNode(
                modelPoint: modelPoint,
                staticPoint: staticPoint,
                distance: distance
                );

            CorrespondenceCollection actual = correspondences;

            correspondences.Add(node);

            modelPointList.Add(modelPoint);
            staticPointList.Add(staticPoint);
            correspondenceList.Add(new Correspondence(staticPoint: staticPoint, modelPoint: modelPoint));
            CorrespondenceCollection expected = new CorrespondenceCollection(modelPointList, staticPointList, correspondenceList);

            Assert.AreEqual(expected, actual);
        }
        public void Test_NonNeutralTransform()
        {
            CorrespondenceCollection correspondences = new CorrespondenceCollection(
                modelpoints: modelPoints,
                staticpoints: staticPoints
                );

            Matrix4x4 expected = new Matrix4x4();

            expected[0, 0] = +1.000000000000000f; expected[0, 1] = -0.000000000000000f; expected[0, 2] = -0.000000000000001f; expected[0, 3] = +3.000000000000021f;
            expected[1, 0] = +0.000000000000000f; expected[1, 1] = +1.000000000000000f; expected[1, 2] = +0.000000000000000f; expected[1, 3] = -2.000000000000009f;
            expected[2, 0] = +0.000000000000001f; expected[2, 1] = -0.000000000000000f; expected[2, 2] = +1.000000000000000f; expected[2, 3] = +0.499999999999987f;
            expected[3, 0] = +0.000000000000000f; expected[3, 1] = +0.000000000000000f; expected[3, 2] = +0.000000000000000f; expected[3, 3] = +1.000000000000000f;

            Matrix4x4 actual = TransformFinder.FindTransform(correspondences);

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    Assert.That(actual[i, j], Is.EqualTo(expected[i, j]).Within(precision));
                }
            }
        }
        public void Test_ComputeError_NormalCorrespondences()
        {
            CorrespondenceCollection correspondences = new CorrespondenceCollection(
                new List <Correspondence> {
                new Correspondence(
                    new Point(new Vector3(1.0f, 2.0f, 3.0f)),
                    new Point(new Vector3(2.0f, 3.0f, 4.0f))
                    ),
                new Correspondence(
                    new Point(new Vector3(3.4f, 4.5f, 5.6f)),
                    new Point(new Vector3(6.7f, 7.8f, 8.9f))
                    ),
                new Correspondence(
                    new Point(new Vector3(9.1f, 2.3f, 3.4f)),
                    new Point(new Vector3(4.5f, 5.6f, 6.7f))
                    )
            }
                );

            float expected = 78.610000f;
            float actual   = errorMetric.ComputeError(correspondences, null, null);

            Assert.That(actual, Is.EqualTo(expected).Within(tolerance));
        }
Example #24
0
 /// <summary>
 /// Computes the error of the correspondences, given that the passed transform is applied to the model points.
 /// </summary>
 /// <returns>The error if the modelTransform is applied to the model points of the correspondences.</returns>
 /// <param name="correspondences">the correspondences</param>
 /// <param name="newTransform">the new transform of the correspondences.</param>
 /// <param name="originalTransform">the original transform of the correspondences.</param>
 public float ComputeError(CorrespondenceCollection correspondences, Transform originalTransform, Transform newTransform)
 {
     return(ComputeErrorAfterTransform(correspondences,
                                       originalTransform, newTransform,
                                       configuration.AggregationMethod));
 }
Example #25
0
        public float ComputeTerminationError(CorrespondenceCollection correspondences, Transform originalTransform, Transform currentTransform)
        {
            float errorSum = ComputeErrorSumAfterTransform(correspondences, originalTransform, currentTransform);

            return(errorSum / (correspondences.Count));
        }
Example #26
0
        public float ComputeError(CorrespondenceCollection correspondences, Transform originalTransform, Transform newTransform)
        {
            float errorSum = ComputeErrorSumAfterTransform(correspondences, originalTransform, newTransform);

            return(errorSum / (4 * correspondences.Count));
        }
Example #27
0
 public float ComputeError(CorrespondenceCollection correspondences, Transform originalTransform, Transform newTransform)
 {
     return(ErrorMetric.Wheeler().ComputeError(correspondences, originalTransform, newTransform));
 }
Example #28
0
 public float ComputeTerminationError(CorrespondenceCollection correspondences, Transform originalTransform, Transform currentTransform)
 {
     return(ErrorMetric.Wheeler().ComputeTerminationError(correspondences, originalTransform, currentTransform));
 }
Example #29
0
 public float ComputeInitialError(CorrespondenceCollection correspondences)
 {
     return(ErrorMetric.Wheeler().ComputeInitialError(correspondences));
 }
Example #30
0
    public _TransformationComputer(StatisticsComputer.RunResult run)
    {
        correspondences = new CorrespondenceCollection();

        this.run = run;
    }