8 #ifndef META_OCEAN_CV_SYNTHESIS_CONSTRAINT_H
9 #define META_OCEAN_CV_SYNTHESIS_CONSTRAINT_H
54 inline Scalar impact()
const;
111 inline Scalar radius()
const;
157 inline const Vector2& point0()
const;
163 inline const Vector2& point1()
const;
182 inline Scalar infiniteLineDistance(
const Vector2& point)
const;
197 std::unique_ptr<Constraint>
copy(
const Scalar scale = 1)
const override;
242 inline Scalar penalty()
const;
248 inline bool finite0()
const;
254 inline bool finite1()
const;
273 inline Scalar finiteLineDistance(
const Vector2& point)
const;
279 std::unique_ptr<Constraint>
copy(
const Scalar scale = 1)
const override;
293 bool finite0_ =
false;
296 bool finite1_ =
false;
348 inline void addConstraint(std::unique_ptr<Constraint> constraint);
354 inline size_t size()
const;
363 void initializeDecisions(
const uint8_t* mask,
const unsigned int width,
const unsigned int height,
const unsigned int maskPaddingElements)
const;
372 inline Scalar cost(
const unsigned int insideX,
const unsigned int insideY,
const Vector2& outside)
const;
382 inline Scalar cost(
const unsigned int insideX,
const unsigned int insideY,
const unsigned int outsideX,
const unsigned int outsideY)
const;
388 inline bool isEmpty()
const;
394 explicit inline operator bool()
const;
434 radiusParameter_(1 / (radius *
Scalar(0.25)))
465 point0_(constraint.point0() * scale),
466 point1_(constraint.point1() * scale)
511 offset_(point1 - point0),
512 offsetSquare_(offset_.
sqr()),
521 LineConstraint(constraint.point0() * scale, constraint.point1() * scale, constraint.impact(), max(
Scalar(2), constraint.radius() * scale)),
522 offset_((constraint.point1() - constraint.point0()) * scale),
523 offsetSquare_(offset_.
sqr()),
524 penalty_(constraint.penalty() * scale),
525 finite0_(constraint.finite0_),
526 finite1_(constraint.finite1_)
576 if (decision == 0xFFu)
586 inline Scalar Constraints::cost(
const unsigned int insideX,
const unsigned int insideY,
const unsigned int outsideX,
const unsigned int outsideY)
const
596 inline Constraints::operator bool()
const
598 return !constraints_.empty();
This class is the base class for all constraints.
Definition: Constraint.h:34
virtual std::unique_ptr< Constraint > copy(const Scalar scale=Scalar(1)) const =0
Creates a copy of this constraint by an optional scale parameter.
Constraint()=default
Creates an empty constraint.
virtual Scalar cost(const Vector2 &inside, const Vector2 &outside) const =0
Returns the cost for a given for two given points.
virtual ~Constraint()=default
Destructs this constraint.
virtual Scalar weight(const Vector2 &point) const =0
Returns the weight of this constraint according to a given point.
Scalar impact() const
Returns the impact factor of this constraint.
Definition: Constraint.h:426
Scalar impact_
Impact factor of this constraint.
Definition: Constraint.h:89
This class implements a container holding constraints.
Definition: Constraint.h:304
void initializeDecisions(const uint8_t *mask, const unsigned int width, const unsigned int height, const unsigned int maskPaddingElements) const
Initializes the constraint decisions.
Frame decisionFrame_
Decision frame.
Definition: Constraint.h:417
Constraints(const Constraints &constraints)
Copy constructor.
ConstraintsVector constraints_
Vector holding the internal constraints.
Definition: Constraint.h:414
void addConstraint(std::unique_ptr< Constraint > constraint)
Adds a new constraint.
Definition: Constraint.h:557
size_t size() const
Returns the number of constraints.
Definition: Constraint.h:562
Constraints & operator=(const Constraints &constraints)=delete
Disabled assign operator.
~Constraints()=default
Destructs the constraint container.
Constraints(const Constraints &constraints, const Scalar scale)
Copies a constraint container and applies an explicit scale factor.
Constraints()=default
Creates a new constraint container.
Constraints & operator=(Constraints &&constraints)=default
Default move operator.
Constraints(Constraints &&constraints)=default
Default move constructor.
Scalar cost(const unsigned int insideX, const unsigned int insideY, const Vector2 &outside) const
Returns the cost for one inside point and one outside point.
Definition: Constraint.h:567
std::vector< std::unique_ptr< Constraint > > ConstraintsVector
Definition of a vector holding constraints.
Definition: Constraint.h:310
bool isEmpty() const
Returns whether this container does not hold any constraint.
Definition: Constraint.h:591
This class implements a finite line constraint.
Definition: Constraint.h:216
Scalar penalty() const
Returns the penalty factor of this line constraint.
Definition: Constraint.h:531
FiniteLineConstraint(const Vector2 &point0, const Vector2 &point1, const Scalar impact, const Scalar radius, const Scalar penalty, const bool finite0, const bool finite1)
Creates a new finite line constraint object.
Definition: Constraint.h:509
std::unique_ptr< Constraint > copy(const Scalar scale=1) const override
Creates a copy of this constraint by an optional scale parameter.
Scalar offsetSquare_
Square length of the offset vector.
Definition: Constraint.h:287
Vector2 offset_
Offset vector between the first and the second point.
Definition: Constraint.h:284
Scalar penalty_
Penalty value.
Definition: Constraint.h:290
bool finite1_
State to finite the line at the second point.
Definition: Constraint.h:296
Scalar weight(const Vector2 &point) const override
Returns the weight of this constraint according to a given point.
bool finite1() const
Returns the finite state of the second point.
Definition: Constraint.h:541
bool finite0() const
Returns the finite state of the first point.
Definition: Constraint.h:536
Scalar cost(const Vector2 &inside, const Vector2 &outside) const override
Returns the cost for a given for two given points.
Scalar finiteLineDistance(const Vector2 &point) const
Returns the distance between a given point and this infinite line.
Definition: Constraint.h:546
bool finite0_
State to finite the line at the first point.
Definition: Constraint.h:293
This class implement a line constraint.
Definition: Constraint.h:134
LineConstraint(const Vector2 &point0, const Vector2 &point1, const Scalar impact, const Scalar radius)
Creates a new line constraint object for infinite lines.
Definition: Constraint.h:444
const Vector2 & point0() const
Returns the first point of this line.
Definition: Constraint.h:482
Vector3 parameter_
Normal (x, y) and distance (z) of the line.
Definition: Constraint.h:208
Scalar infiniteLineDistance(const Vector2 &point) const
Returns the distance between a given point and this infinite line.
Definition: Constraint.h:492
Scalar weight(const Vector2 &point) const override
Returns the weight of this constraint according to a given point.
Scalar cost(const Vector2 &inside, const Vector2 &outside) const override
Returns the cost for a given for two given points.
Vector2 point1_
Second point of the line.
Definition: Constraint.h:205
Vector2 point0_
First point of the line.
Definition: Constraint.h:202
const Vector2 & point1() const
Returns the second point of this line.
Definition: Constraint.h:487
std::unique_ptr< Constraint > copy(const Scalar scale=1) const override
Creates a copy of this constraint by an optional scale parameter.
This class implements a structure constraint.
Definition: Constraint.h:97
Scalar radius_
Impact radius of this structure constraint.
Definition: Constraint.h:123
Scalar radiusParameter_
Radius parameter of this constraint: 1 / (1/4 * radius)
Definition: Constraint.h:126
Scalar radius() const
Returns the radius of this constraint.
Definition: Constraint.h:439
StructureConstraint(const Scalar impact, const Scalar radius)
Creates a new structure constraint object.
Definition: Constraint.h:431
virtual Scalar weight(const Vector2 &point) const =0
Returns the weight of this constraint according to a given point.
This class implements Ocean's image class.
Definition: Frame.h:1792
bool isValid() const
Returns whether this frame is valid.
Definition: Frame.h:4448
const T * constpixel(const unsigned int x, const unsigned int y, const unsigned int planeIndex=0u) const
Returns the pointer to the constant data of a specific pixel.
Definition: Frame.h:4250
unsigned int width() const
Returns the width of the frame format in pixel.
Definition: Frame.h:3143
unsigned int height() const
Returns the height of the frame in pixel.
Definition: Frame.h:3148
static T exp(const T value)
Returns the base-e exponential function of a given value.
Definition: Numeric.h:1643
static T abs(const T value)
Returns the absolute value of a given value.
Definition: Numeric.h:1220
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition: Numeric.h:2386
static constexpr T sqr(const T value)
Returns the square of a given value.
Definition: Numeric.h:1495
static constexpr bool isNotEqualEps(const T value)
Returns whether a value is not smaller than or equal to a small epsilon.
Definition: Numeric.h:2237
const T & x() const noexcept
Returns the x value.
Definition: Vector2.h:698
const T & y() const noexcept
Returns the y value.
Definition: Vector2.h:710
T length() const
Returns the length of the vector.
Definition: Vector2.h:615
VectorT2< T > perpendicular() const
Returns a vector perpendicular to this vectors.
Definition: Vector2.h:550
const T & y() const noexcept
Returns the y value.
Definition: Vector3.h:812
const T & x() const noexcept
Returns the x value.
Definition: Vector3.h:800
const T & z() const noexcept
Returns the z value.
Definition: Vector3.h:824
unsigned int sqr(const char value)
Returns the square value of a given value.
Definition: base/Utilities.h:1029
float Scalar
Definition of a scalar type.
Definition: Math.h:128
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition: Vector3.h:22
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15