5# include "../_cexports/c_foundation.h"
6# include "cvb/area_2d.hpp"
7# include "cvb/line_2d.hpp"
8# include "cvb/matrix_2d.hpp"
38 int resampledCurveLength)
41 Internal::DoResCall([&]() {
43 reinterpret_cast<const CExports::CVIPointD *
>(curve.data()),
44 static_cast<CExports::cvbdim_t
>(curve.size()),
45 static_cast<CExports::cvbdim_t
>(resampledCurve.size()),
46 reinterpret_cast<CExports::CVIPointD *
>(resampledCurve.data()));
48 return resampledCurve;
67 class AlignmentConfiguration
70 AlignmentConfiguration() noexcept
73 , minImprovement_(1e-3)
90 : maxIterations_(maxIterations)
91 , tolerance_(tolerance)
92 , minImprovement_(minImprovement)
93 , correspondence_(correspondence)
111 return maxIterations_;
121 maxIterations_ = maxIterations;
144 tolerance_ = tolerance;
157 return minImprovement_;
167 minImprovement_ = minImprovement;
179 return correspondence_;
191 correspondence_ = correspondence;
215 size_t maxIterations_;
217 double minImprovement_;
218 double correspondence_;
67 class AlignmentConfiguration {
…};
225 class AlignmentResult2D
228 AlignmentResult2D(
const AlignmentResult2D &)
noexcept =
default;
229 AlignmentResult2D(AlignmentResult2D &&)
noexcept =
default;
231 AlignmentResult2D &operator=(
const AlignmentResult2D &) =
default;
232 AlignmentResult2D &operator=(AlignmentResult2D &&) =
default;
261 return meanDistance_;
271 return numIterations_;
277 , numIterations_(0) {};
281 double meanDistance_;
282 size_t numIterations_;
225 class AlignmentResult2D {
…};
310 AlignmentResult2D result;
311 Internal::DoResCall([&]() {
312 return CVB_CALL_CAPI(
CVFAlignCurves2D(
reinterpret_cast<const CExports::CVIPointD *
>(curve.data()),
313 static_cast<CExports::cvbdim_t
>(curve.size()),
314 reinterpret_cast<const CExports::CVIPointD *
>(curveToBeAligned.data()),
315 static_cast<CExports::cvbdim_t
>(curveToBeAligned.size()),
316 reinterpret_cast<const CExports::CVFAlignmentConfiguration &
>(config),
317 reinterpret_cast<CExports::CVFAlignment2DResult &
>(result)));
341 Internal::DoResCall([&]() {
342 return CVB_CALL_CAPI(
344 static_cast<CExports::cvbdim_t
>(curve.size()),
345 reinterpret_cast<const CExports::CVIPointD *
>(points.data()),
346 static_cast<CExports::cvbdim_t
>(points.size()), differences.data()));
378 auto intersectionPointsCalculatedLength = intersectionPoints.size();
379 auto normal = line.
Normal();
380 Internal::DoResCall([&]() {
382 reinterpret_cast<const CExports::CVIPointD *
>(curve.data()),
383 static_cast<CExports::cvbdim_t
>(curve.size()), *
reinterpret_cast<const CExports::CVIPointD *
>(&normal),
384 line.
Distance(),
static_cast<CExports::cvbdim_t
>(intersectionPoints.size()),
385 reinterpret_cast<CExports::CVIPointD *
>(intersectionPoints.data()),
386 reinterpret_cast<CExports::cvbdim_t &
>(intersectionPointsCalculatedLength)));
388 intersectionPoints.resize(intersectionPointsCalculatedLength);
389 return intersectionPoints;
419 double enclosedArea = 0;
420 Internal::DoResCall([&]() {
422 static_cast<CExports::cvbdim_t
>(curve.size()), &enclosedArea));
445 Internal::DoResCall([&]() {
447 reinterpret_cast<const CExports::CVIPointD *
>(curve.data()),
448 static_cast<CExports::cvbdim_t
>(curve.size()),
449 reinterpret_cast<const CExports::CVIPointD *
>(points.data()),
450 static_cast<CExports::cvbdim_t
>(points.size()),
reinterpret_cast<double *
>(&distance)));
506 int mergedLength = 0;
507 Internal::DoResCall([&]() {
508 return CVB_CALL_CAPI(
CVFMerge2Curves(
reinterpret_cast<const CExports::CVIPointD *
>(curveLHS.data()),
509 static_cast<CExports::cvbdim_t
>(curveLHS.size()),
510 reinterpret_cast<const CExports::CVIPointD *
>(curveRHS.data()),
511 static_cast<CExports::cvbdim_t
>(curveRHS.size()),
513 static_cast<CExports::cvbdim_t
>(mergedCurve.size()),
514 reinterpret_cast<CExports::CVIPointD *
>(mergedCurve.data()),
515 reinterpret_cast<CExports::cvbdim_t &
>(mergedLength)));
517 if (mergedLength !=
static_cast<int>(mergedCurve.size()))
518 mergedCurve.resize(mergedLength);
524 using Curve::AlignmentConfiguration;
525 using Curve::AlignmentResult2D;
A set of parameters that configures an alignment operation.
Definition curve.hpp:68
AlignmentConfiguration(size_t maxIterations, double tolerance, double minImprovement, double correspondence, PreAlignmentMode mode) noexcept
Constructor for an alignment configuration.
Definition curve.hpp:88
double Tolerance() const noexcept
Gets the value for early stopping criteria.
Definition curve.hpp:132
PreAlignmentMode Mode() const noexcept
Gets the pre-align mode.
Definition curve.hpp:199
void SetTolerance(double tolerance) noexcept
Sets the value for early stopping criteria.
Definition curve.hpp:142
size_t MaxIterations() const noexcept
Gets the maximum iterations of ICP.
Definition curve.hpp:109
void SetMode(PreAlignmentMode mode) noexcept
Sets the pre-align mode.
Definition curve.hpp:209
void SetCorrespondence(double correspondence) noexcept
Sets the minimum value for correspondence of two points to be considered for alignment.
Definition curve.hpp:189
double MinImprovement() const noexcept
Gets the value for early stopping criteria.
Definition curve.hpp:155
void SetMinImprovement(double minImprovement) noexcept
Sets the value for early stopping criteria.
Definition curve.hpp:165
void SetMaxIterations(size_t maxIterations) noexcept
Sets the maximum iterations of ICP.
Definition curve.hpp:119
double Correspondence() const noexcept
Gets the minimum value for correspondence of two points to be considered for alignment.
Definition curve.hpp:177
A set of parameters that stores the result of alignment operation.
Definition curve.hpp:226
friend AlignmentResult2D AlignCurve(const std::vector< Point2D< double > > &, const std::vector< Point2D< double > > &, const AlignmentConfiguration &)
Aligns two 2D curves via an iterative closest point method considering consensus correspondence for b...
Definition curve.hpp:306
size_t NumIterations() const noexcept
Gets the number of iterations needed for alignment.
Definition curve.hpp:269
const Matrix2D & Rotation() const noexcept
Gets the estimated rotation.
Definition curve.hpp:239
double MeanDistance() const noexcept
Gets the mean distance between reference and aligned curve.
Definition curve.hpp:259
const Vector2D< double > & Translation() const noexcept
Gets the estimated translation.
Definition curve.hpp:249
Object representing an infinite line in 2 dimensional space.
Definition line_2d.hpp:16
double Distance() const noexcept
Gets the distance of the line from the origin.
Definition line_2d.hpp:77
Point2D< double > Normal() const noexcept
Gets the normal vector of the line.
Definition line_2d.hpp:56
Double precision 2x2 matrix class.
Definition matrix_2d.hpp:16
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
cvbres_t CVFCalculateSignedDifferences(const CVIPointD *Curve, cvbdim_t CurveLength, const CVIPointD *Points, cvbdim_t PointsLength, double *SignedDifferences)
cvbres_t CVFResampleCurve2D(const CVIPointD *Curve, cvbdim_t CurveLength, cvbdim_t ResampledCurveLength, CVIPointD *ResampledCurve)
cvbres_t CVFCalculateEnclosedArea(const CVIPointD *Curve, cvbdim_t CurveLength, double *EnclosedArea)
cvbres_t CVFAlignCurves2D(const CVIPointD *Curve, cvbdim_t CurveLength, const CVIPointD *CurveToBeAligned, cvbdim_t CurveToBeAlignedLength, const CVFAlignmentConfiguration &Config, CVFAlignment2DResult &Result)
cvbres_t CVFCalculateQuadraticDifferencesToClosestPoint(const CVIPointD *Curve, cvbdim_t CurveLength, const CVIPointD *Points, cvbdim_t PointsLength, double *Differences)
cvbres_t CVFIntersectCurve2DWithLine(const CVIPointD *Curve, cvbdim_t CurveLength, CVIPointD Normal, double DistanceToOrigin, cvbdim_t IntersectionPointsLength, CVIPointD *IntersectionPoints, cvbdim_t &IntersectionPointsCalculatedLength)
cvbres_t CVFMerge2Curves(const CVIPointD *CurveLHS, cvbdim_t CurveLengthLHS, const CVIPointD *CurveRHS, cvbdim_t CurveLengthRHS, cvbbool_t sort, cvbdim_t CurveOutAllocatedLength, CVIPointD *CurveOut, cvbdim_t &CurveOutLength)
Namespace for collection of 2D curve functions from the Foundation package.
Definition curve.hpp:24
double CalculateEnclosedArea(const std::vector< Point2D< double > > &curve)
Calculates the enclosed area of the given curve.
Definition curve.hpp:417
Matrix2D CalculateQuadraticDifferencesToClosestPoint(const std::vector< Point2D< double > > &curve, const std::vector< Point2D< double > > &points)
Calculates the quadratic distance of the points to the closest point of the given curve.
Definition curve.hpp:441
std::vector< double > CalculateSignedDifferences(const std::vector< Point2D< double > > &curve, const std::vector< Point2D< double > > &points)
Calculates signed differences along the y axis of given points to curve (curve - points).
Definition curve.hpp:337
AlignmentResult2D AlignCurve(const std::vector< Point2D< double > > &curve, const std::vector< Point2D< double > > &curveToBeAligned, const AlignmentConfiguration &config=AlignmentConfiguration())
Aligns two 2D curves via an iterative closest point method considering consensus correspondence for b...
Definition curve.hpp:306
std::vector< Point2D< double > > IntersectWithLine(const std::vector< Point2D< double > > &curve, const Line2D &line)
Intersects a 2D curve with a line.
Definition curve.hpp:374
StartSelectionMode
Decides which start point should be used for the new curve.
Definition curve.hpp:457
@ AsIs
Definition curve.hpp:461
@ Best
Definition curve.hpp:465
std::vector< Point2D< double > > ResampleCurve(const std::vector< Point2D< double > > &curve, int resampledCurveLength)
Resamples a 2-dimensional curve via linear interpolation assuming that the "speed" of the time mappin...
Definition curve.hpp:37
PreAlignmentMode
Specifies if the pre-alignment is required.
Definition curve.hpp:53
@ On
Definition curve.hpp:61
@ Off
Definition curve.hpp:57
std::vector< Point2D< double > > MergeTwoCurves(const std::vector< Point2D< double > > &curveLHS, const std::vector< Point2D< double > > &curveRHS, const StartSelectionMode &mode)
Merges two curves into one curve with interpolation.
Definition curve.hpp:501
Namespace for the Foundation package.
Definition decl_metric_aqs12_calibration_piece.hpp:11
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
Point2D< T > Vector2D
Alias for Point2D.
Definition point_2d.hpp:379