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 Configuration( DistanceMetrics.Metric distanceMetric = null, bool normalizePoints = true, AggregationMethods.AggregationMethod aggregationMethod = null ) { DistanceMetric = distanceMetric ?? DistanceMetrics.SquaredEuclidean; NormalizePoints = normalizePoints; AggregationMethod = aggregationMethod ?? AggregationMethods.Sum; }
private static string AggregationMethodToString(AggregationMethods.AggregationMethod aggregationMethod) { AggregationMethods.AggregationMethod mean = AggregationMethods.Mean; if (aggregationMethod.Equals(mean)) { return("mean"); } AggregationMethods.AggregationMethod sum = AggregationMethods.Sum; if (aggregationMethod.Equals(sum)) { return("sum"); } return("unkown aggregatin method"); }