8#ifndef META_OCEAN_TRACKING_SLAM_OCCUPANCY_ARRAY_H
9#define META_OCEAN_TRACKING_SLAM_OCCUPANCY_ARRAY_H
53 OccupancyArray(
const Scalar left,
const Scalar top,
const unsigned int width,
const unsigned int height,
const unsigned int horizontalBins,
const unsigned int verticalBins,
const unsigned int neighborhoodSize = 3u,
const float minCoverageThreshold = 0.8f);
59 inline void addPoint(
const Vector2& imagePoint);
66 void addPoint(
const unsigned int xBin,
const unsigned int yBin);
74 inline bool addPointIfEmpty(
const Vector2& imagePoint);
83 inline bool addPointIfWithinLimit(
const Vector2& imagePoint,
const unsigned int maxPoints);
110 inline bool isEmpty(
const Vector2& imagePoint)
const;
119 bool isEmpty(
const unsigned int xBin,
const unsigned int yBin)
const;
124 inline void removePoints();
131 inline bool needMorePoints()
const;
137 inline bool isValid()
const;
143 inline unsigned int width()
const;
149 inline unsigned int height()
const;
156 inline float coverage()
const;
164 size_t numberPoints_ = 0;
167 float coverageThreshold_ = -1.0f;
170 unsigned int neighborhoodRadius_ = 0u;
236 return (
unsigned int)(Array::width());
241 return (
unsigned int)(Array::height());
248 return float(
numberPoints_ * neighborhoodSize * neighborhoodSize) / float(
bins());
This class implements a base class for data arrays.
Definition SpatialDistribution.h:37
unsigned int horizontalBins() const
Returns the number of horizontal distribution bins.
Definition SpatialDistribution.h:1078
int horizontalBin(const Scalar x) const
Returns the horizontal bin of a given horizontal position.
Definition SpatialDistribution.h:1104
int verticalBin(const Scalar y) const
Returns the vertical bin of a given vertical position.
Definition SpatialDistribution.h:1110
unsigned int verticalBins() const
Returns the number of vertical distribution bins.
Definition SpatialDistribution.h:1083
unsigned int bins() const
Returns the number of bins this distribution holds.
Definition SpatialDistribution.h:1088
This class implements an occupancy array allowing to keep track of occupied and unoccupied bins in a ...
Definition OccupancyArray.h:32
void removePoints()
Removes all points from the occupancy array.
Definition OccupancyArray.h:217
OccupancyArray(const Scalar left, const Scalar top, const unsigned int width, const unsigned int height, const unsigned int horizontalBins, const unsigned int verticalBins, const unsigned int neighborhoodSize=3u, const float minCoverageThreshold=0.8f)
Creates a new occupancy array.
void addPoint(const Vector2 &imagePoint)
Adds a new point.
Definition OccupancyArray.h:173
bool addPointIfEmpty(const Vector2 &imagePoint)
Adds a new point only if the neighborhood around the bin is empty (not yet occupied).
Definition OccupancyArray.h:184
bool addPointIfWithinLimit(const Vector2 &imagePoint, const unsigned int maxPoints)
Adds a new point only if the neighborhood will not exceed the specified number of points after adding...
Definition OccupancyArray.h:195
Indices32 bins_
The vector holding occupancy counters for all bins.
Definition OccupancyArray.h:161
OccupancyArray()=default
Default constructor to create an invalid array.
unsigned int height() const
Returns the height of the distribution area.
Definition OccupancyArray.h:239
float coverage() const
Returns the fraction of bins that are occupied, normalized by neighborhood size.
Definition OccupancyArray.h:244
float coverageThreshold_
The coverage threshold to determine if more points are needed.
Definition OccupancyArray.h:167
bool isEmpty(const Vector2 &imagePoint) const
Returns whether the neighborhood around the given image point is empty (not yet occupied).
Definition OccupancyArray.h:206
bool addPointIfWithinLimit(const unsigned int xBin, const unsigned int yBin, const unsigned int maxPoints)
Adds a new point only if the neighborhood will not exceed the specified number of points after adding...
size_t numberPoints_
The number of points added to the occupancy array.
Definition OccupancyArray.h:164
unsigned int width() const
Returns the width of the distribution area.
Definition OccupancyArray.h:234
bool needMorePoints() const
Returns whether more points are needed to ensure a good distribution of the points in the image.
Definition OccupancyArray.h:224
void addPoint(const unsigned int xBin, const unsigned int yBin)
Adds a new point.
bool addPointIfEmpty(const unsigned int xBin, const unsigned int yBin)
Adds a new point only if the neighborhood around the bin is empty (not yet occupied).
bool isValid() const
Returns whether this array is valid.
Definition OccupancyArray.h:229
unsigned int neighborhoodRadius_
The neighborhood radius (offset from center bin), e.g., 1 for 3x3 neighborhood, 2 for 5x5,...
Definition OccupancyArray.h:170
bool isEmpty(const unsigned int xBin, const unsigned int yBin) const
Returns whether the neighborhood around the given bin is empty (not yet occupied).
const T & x() const noexcept
Returns the x value.
Definition Vector2.h:710
const T & y() const noexcept
Returns the y value.
Definition Vector2.h:722
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15