Ocean
NonLinearOptimizationLine.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_LINE_H
9 #define META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_LINE_H
10 
13 
14 #include "ocean/math/Line2.h"
15 
16 namespace Ocean
17 {
18 
19 namespace Geometry
20 {
21 
22 /**
23  * This class implements least square or robust optimization algorithms optimizing lines.
24  * @ingroup geometry
25  */
26 class OCEAN_GEOMETRY_EXPORT NonLinearOptimizationLine : protected NonLinearOptimization
27 {
28  protected:
29 
30  /**
31  * Forward declaration of a data object allowing to optimize a 2D plane.
32  */
33  class LineData;
34 
35  public:
36 
37  /**
38  * Optimizes a 2D line by reducing the distance between image points and their projected line points.
39  * @param line Line that has to be optimized
40  * @param pointAccessor The accessor providing the 2D points that define the 2D line, at least two points
41  * @param optimizedLine Resulting optimized line with reduced (optimized) distance between image points and projected line points
42  * @param iterations Number of iterations to be applied at most, if no convergence can be reached in the meantime, with range [1, infinity)
43  * @param estimator Robust error estimator to be used
44  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
45  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
46  * @param initialError Optional resulting averaged pixel error for the given initial parameters, w.r.t. the defined estimator
47  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, w.r.t. the defined estimator
48  * @return Result of the optimization
49  */
50  static bool optimizeLine(const Line2& line, const ConstIndexedAccessor<ImagePoint>& pointAccessor, Line2& optimizedLine, const unsigned int iterations = 20u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr);
51 };
52 
53 }
54 
55 }
56 
57 #endif // META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_LINE_H
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition: Accessor.h:241
EstimatorType
Definition of individual robust estimator types.
Definition: Estimator.h:34
@ ET_SQUARE
The standard square error estimator (L2).
Definition: Estimator.h:52
This class implements the basic functions for least square or robust optimization algorithms for non ...
Definition: NonLinearOptimization.h:34
This class implements least square or robust optimization algorithms optimizing lines.
Definition: NonLinearOptimizationLine.h:27
static bool optimizeLine(const Line2 &line, const ConstIndexedAccessor< ImagePoint > &pointAccessor, Line2 &optimizedLine, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr)
Optimizes a 2D line by reducing the distance between image points and their projected line points.
This class implements an infinite line in 2D space.
Definition: Line2.h:83
float Scalar
Definition of a scalar type.
Definition: Math.h:128
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15