8 #ifndef META_OCEAN_CV_SEGMENTATION_CONTOUR_FINDER_H
9 #define META_OCEAN_CV_SEGMENTATION_CONTOUR_FINDER_H
26 namespace Segmentation
42 template <
unsigned int tChannels>
67 inline Fingerprint(
const uint8_t*
const frame,
const unsigned int frameStrideElements,
const PixelPosition& fingerprintLocation);
78 inline bool isSimilar(
const uint8_t*
const frame,
const unsigned int frameStrideElements,
const PixelPosition& position,
const unsigned int maximalSqrDistances[tChannels])
const;
87 inline bool isSimilar(
const uint8_t*
const frameLocation,
const unsigned int maximalSqrDistances[tChannels])
const;
93 const Type& data()
const;
100 inline uint8_t operator[](
const unsigned int index)
const;
139 template <
unsigned int tChannels>
171 template <
unsigned int tChannels>
172 static bool findBorderLandmarks8BitPerChannel(
const uint8_t* frame,
const uint8_t* roughMask,
const unsigned int width,
const unsigned int height,
const unsigned int framePaddingElements,
const unsigned int roughMaskPaddingElements,
const PixelContour& roughContour,
const unsigned int extraOffset,
Vectors2& landmarks);
199 template <
unsigned int tChannels>
217 template <
unsigned int tChannels>
218 static void similarityMask8BitPerChannel(
const uint8_t* frame,
const uint8_t* roughMask, uint8_t* fineMask,
const unsigned int width,
const unsigned int height,
const unsigned int framePaddingElements,
const unsigned int roughMaskPaddingElements,
const unsigned int fineMaskPaddingElements,
const PixelContour& roughContour,
const unsigned int variances[tChannels],
Worker* worker);
235 template <
unsigned int tChannels>
257 template <
unsigned int tChannels>
258 static void similarityMask8BitPerChannelSubset(
const uint8_t* frame,
const uint8_t* roughMask, uint8_t* fineMask,
const unsigned int width,
const unsigned int height,
const unsigned int frameStrideElements,
const unsigned int roughMaskStrideElements,
const unsigned int fineMaskStrideElements,
const Fingerprint<tChannels>* fingerprints,
const size_t numberFingerprints,
const unsigned int variances[tChannels],
const unsigned int firstColumn,
const unsigned int numberColumns,
const unsigned int firstRow,
const unsigned int numberRows);
275 template <
unsigned int tChannels>
279 template <
unsigned int tChannels>
282 ocean_assert(frame !=
nullptr);
283 ocean_assert(fingerprintLocation.
x() < frameStrideElements);
285 data_ = *(
const Type*)(frame + fingerprintLocation.
y() * frameStrideElements + fingerprintLocation.
x() * tChannels);
288 template <
unsigned int tChannels>
291 ocean_assert(frame !=
nullptr && frameStrideElements != 0u && maximalSqrDistances);
292 ocean_assert(position.
x() < frameStrideElements);
294 const uint8_t*
const fingerprint = (uint8_t*)(&data_);
295 const uint8_t*
const frameData = frame + position.
y() + frameStrideElements + position.
x() * tChannels;
299 for (
unsigned int n = 0u; n < tChannels; ++n)
301 if (
sqrDistance(fingerprint[n], frameData[n]) > maximalSqrDistances[n])
310 template <
unsigned int tChannels>
313 ocean_assert(frameLocation && maximalSqrDistances);
315 const uint8_t*
const fingerprint = (uint8_t*)(&data_);
319 for (
unsigned int n = 0u; n < tChannels; ++n)
321 if (
sqrDistance(fingerprint[n], frameLocation[n]) > maximalSqrDistances[n])
330 template <
unsigned int tChannels>
336 template <
unsigned int tChannels>
339 ocean_assert(index < tChannels);
341 return ((
const uint8_t*)(&data_))[index];
T y() const
Returns the vertical coordinate position of this object.
Definition: PixelPosition.h:470
T x() const
Returns the horizontal coordinate position of this object.
Definition: PixelPosition.h:458
This class implements a fingerprint based on arbitrary visual information which can be used to determ...
Definition: ContourFinder.h:44
bool isSimilar(const uint8_t *const frame, const unsigned int frameStrideElements, const PixelPosition &position, const unsigned int maximalSqrDistances[tChannels]) const
Returns whether this fingerprint is similar to the visual information in a frame at a specified locat...
Definition: ContourFinder.h:289
Type data_
The data information of this fingerprint.
Definition: ContourFinder.h:105
std::vector< Fingerprint< tChannels > > Fingerprints
Definition of a vector holding fingerprint objects.
Definition: ContourFinder.h:50
Fingerprint(const uint8_t *const frame, const unsigned int frameStrideElements, const PixelPosition &fingerprintLocation)
Creates a new fingerprint object while the fingerprint's data is extracted from a specified frame (or...
Definition: ContourFinder.h:280
const Type & data() const
Returns the data of this finger print.
Definition: ContourFinder.h:331
uint8_t operator[](const unsigned int index) const
Returns the fingerprint value of one specific data channel.
Definition: ContourFinder.h:337
DataType< uint8_t, tChannels >::Type Type
Definition of a data type storing the information of one fingerprint.
Definition: ContourFinder.h:57
This class implements functions finding contours.
Definition: ContourFinder.h:34
static void similarityMask8BitPerChannel(const uint8_t *frame, const uint8_t *roughMask, uint8_t *fineMask, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const unsigned int roughMaskPaddingElements, const unsigned int fineMaskPaddingElements, const PixelContour &roughContour, const unsigned int variances[tChannels], Worker *worker)
Determines the similarity mask of an object visible in a frame which's visual information is not simi...
static void similarityMaskPyramid8BitPerChannel(const Frame &frame, const Frame &roughMask, const PixelContour &roughContour, const unsigned int variances[tChannels], const bool oneObject, const unsigned int layers, Frame &fineMaskResult, Worker *worker)
Determines the similarity mask of an object visible in a frame which's visual information is not simi...
static PixelContour similarityContour8BitPerChannel(const uint8_t *frame, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const unsigned int window, const PixelContour &roughContour, const unsigned int extraOffset, RandomGenerator &randomGenerator, Worker *worker=nullptr)
Determines the contour of an object visually different from the visual content around a rough contour...
static bool findBorderLandmarks8BitPerChannel(const uint8_t *frame, const uint8_t *roughMask, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const unsigned int roughMaskPaddingElements, const PixelContour &roughContour, const unsigned int extraOffset, Vectors2 &landmarks)
Determines fixed landmark locations around the border of an object within a frame and within a rough ...
static void similarityMask8BitPerChannelSubset(const uint8_t *frame, const uint8_t *roughMask, uint8_t *fineMask, const unsigned int width, const unsigned int height, const unsigned int frameStrideElements, const unsigned int roughMaskStrideElements, const unsigned int fineMaskStrideElements, const Fingerprint< tChannels > *fingerprints, const size_t numberFingerprints, const unsigned int variances[tChannels], const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows)
Determines the similarity mask of an object visible in a subset of a frame which's visual information...
static void finetuneSimilarityMask8BitPerChannel(const uint8_t *frame, uint8_t *mask, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const unsigned int maskPaddingElements, const PixelContour &roughContour, const CV::PixelPositions &positions, const unsigned int variances[tChannels], Worker *worker)
Finetunes specific locations in a mask (e.g., for pixels at the mask's border) currently rated as mas...
static bool findBorderLandmarks(const Frame &frame, const Frame &roughMask, const PixelContour &roughContour, const unsigned int extraOffset, Vectors2 &landmarks)
Determines fixed landmark locations around the border of an object within a frame and within a rough ...
static void finetuneSimilarityMask8BitPerChannelSubset(const uint8_t *frame, uint8_t *mask, const unsigned int frameStrideElements, const unsigned int maskStrideElements, const Fingerprint< tChannels > *fingerprints, const size_t numberFingerprints, const unsigned int variances[tChannels], const CV::PixelPosition *positions, const unsigned int firstPosition, const unsigned int numberPositions)
Finetunes a subset of specific locations in a mask (e.g., for pixels at the mask's border) currently ...
static bool adjustContourWithLandmarks(const Vectors2 &contour, const Vectors2 &landmarks, Vectors2 &adjustedContour, const bool aggressive=false)
Adjusts the location and shape of a given contour to a set of given landmark locations.
static PixelContour similarityContour(const Frame &frame, const unsigned int window, const PixelContour &roughContour, const unsigned int extraOffset, RandomGenerator &randomGenerator, Worker *worker=nullptr)
Determines the contour of an object visually different from the visual content around a rough contour...
Template class allowing to define an array of data types.
Definition: DataType.h:27
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition: base/Utilities.h:1089
std::vector< PixelPosition > PixelPositions
Definition of a vector holding pixel positions (with positive coordinate values).
Definition: PixelPosition.h:48
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15