Ocean
ContourFinder.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_CV_SEGMENTATION_CONTOUR_FINDER_H
9 #define META_OCEAN_CV_SEGMENTATION_CONTOUR_FINDER_H
10 
13 
14 #include "ocean/base/Frame.h"
16 #include "ocean/base/Worker.h"
17 
18 #include <vector>
19 
20 namespace Ocean
21 {
22 
23 namespace CV
24 {
25 
26 namespace Segmentation
27 {
28 
29 /**
30  * This class implements functions finding contours.
31  * @ingroup cvsegmentation
32  */
33 class OCEAN_CV_SEGMENTATION_EXPORT ContourFinder
34 {
35  protected:
36 
37  /**
38  * This class implements a fingerprint based on arbitrary visual information which can be used to determine similarity or dissimilarity between other visual information (e.g., specific locations in a frame).
39  * The fingerprint stores 8 bit per data channel.
40  * @tparam tChannels The number of data channels each fingerprint holds, with range [1, infinity)
41  */
42  template <unsigned int tChannels>
44  {
45  public:
46 
47  /**
48  * Definition of a vector holding fingerprint objects.
49  */
50  typedef typename std::vector<Fingerprint<tChannels>> Fingerprints;
51 
52  protected:
53 
54  /**
55  * Definition of a data type storing the information of one fingerprint.
56  */
58 
59  public:
60 
61  /**
62  * Creates a new fingerprint object while the fingerprint's data is extracted from a specified frame (or buffer) with 'tChannels' data channels at a specified location.
63  * @param frame The frame from which the fingerprint information is extracted, with 'tChannels' data channels, must be valid
64  * @param frameStrideElements The number of elements between two frame row, in elements, with range [width * tChannels, infinity)
65  * @param fingerprintLocation The location of the fingerprint, with range [0, width)x[0, height)
66  */
67  inline Fingerprint(const uint8_t* const frame, const unsigned int frameStrideElements, const PixelPosition& fingerprintLocation);
68 
69  /**
70  * Returns whether this fingerprint is similar to the visual information in a frame at a specified location.
71  * Similarity is determined based on the channel-wise square distance between the fingerprint data and the data of the frame.<br>
72  * The square distance between the information of each fingerprint channel and frame channel must be below the individual channel-based threshold parameters.
73  * @param frame The frame which will be used for the comparison, with 'tChannels' data channels, must be valid
74  * @param frameStrideElements The number of elements between two frame row, in elements, with range [width * tChannels, infinity)
75  * @param position The position inside the frame where the fingerprint comparison will be applied, with range [0, width)x[0, height)
76  * @param maximalSqrDistances The maximal square distances between frame data and fingerprint data, one for each data channel, with range [0, 255 * 255)
77  */
78  inline bool isSimilar(const uint8_t* const frame, const unsigned int frameStrideElements, const PixelPosition& position, const unsigned int maximalSqrDistances[tChannels]) const;
79 
80  /**
81  * Returns whether this fingerprint is similar to the visual information at a specific frame location.
82  * Similarity is determined based on the channel-wise square distance between the fingerprint data and the data of the frame.<br>
83  * The square distance between the information of each fingerprint channel and frame channel must be below the individual channel-based threshold parameters.
84  * @param frameLocation The location in the frame which will be used for the comparison, with 'tChannels' data channels, must be valid
85  * @param maximalSqrDistances The maximal square distances between frame data and fingerprint data, one for each data channel, with range [0, 255 * 255)
86  */
87  inline bool isSimilar(const uint8_t* const frameLocation, const unsigned int maximalSqrDistances[tChannels]) const;
88 
89  /**
90  * Returns the data of this finger print.
91  * @return The fingerprint's data
92  */
93  const Type& data() const;
94 
95  /**
96  * Returns the fingerprint value of one specific data channel.
97  * @param index The index of the data channel for which the value will be returned, with range [0, tChannels)
98  * @return The value of the fingerprint's channel
99  */
100  inline uint8_t operator[](const unsigned int index) const;
101 
102  protected:
103 
104  /// The data information of this fingerprint.
106  };
107 
108  public:
109 
110  /**
111  * Determines the contour of an object visually different from the visual content around a rough contour (very roughly) surrounding the object.
112  * This function actually invoked similarityContour8BitPerChannel() depending on the number of frame channels.
113  * @param frame The frame showing the object, in which the rough contour is defined and for which the fine contour will be determined
114  * @param window The window size for the mean filter that is applied internally before the contour is determined, with range [1, infinity), must be odd
115  * @param roughContour The rough contour (very roughly) enclosing the object for which the fine contour will be determined
116  * @param extraOffset The explicit additional offset between the actual object and the final resulting contour in pixel, with range [0, infinity)
117  * @param randomGenerator Random number generator object
118  * @param worker Optional worker object to distribute the computation
119  * @return The resulting accurate and dense contour, an empty contour if the contour determination failed
120  * @see similarityContour8BitPerChannel().
121  */
122  static PixelContour similarityContour(const Frame& frame, const unsigned int window, const PixelContour& roughContour, const unsigned int extraOffset, RandomGenerator& randomGenerator, Worker* worker = nullptr);
123 
124  /**
125  * Determines the contour of an object visually different from the visual content around a rough contour (very roughly) surrounding the object.
126  * @param frame The frame showing the object, in which the rough contour is defined and for which the fine contour will be determined
127  * @param width The width of the given frame in pixel, with range [1, infinity)
128  * @param height The height of the given frame in pixel, with range [1, infinity)
129  * @param framePaddingElements The number of padding elements at the end of each frame row, in elements, with range [0, infinity)
130  * @param window The window size for the mean filter that is applied internally before the contour is determined, with range [1, infinity), must be odd
131  * @param roughContour The rough contour (very roughly) enclosing the object for which the fine contour will be determined
132  * @param extraOffset The explicit additional offset between the actual object and the final resulting contour in pixel, with range [0, infinity)
133  * @param randomGenerator Random number generator object
134  * @param worker Optional worker object to distribute the computation
135  * @return The resulting accurate and dense contour, an empty contour if the contour determination failed
136  * @tparam tChannels The number of channels the provided frame has, with range [1, infinity)
137  * @see similarityContour().
138  */
139  template <unsigned int tChannels>
140  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);
141 
142  /**
143  * Determines fixed landmark locations around the border of an object within a frame and within a rough contour.
144  * This function uses fingerprints around a specified rough contour to identify the landmarks.
145  * @param frame The frame in which the object is visible and for which the landmarks will be determined, must be valid
146  * @param roughMask The rough 8 bit mask covering the object, with same frame dimension and pixel origin as the provided frame, must be valid
147  * @param roughContour The rough contour around the object, with ranges [0, frame.width())x[0, frame.height())
148  * @param extraOffset The explicit additional offset between the actual object and the final resulting contour in pixel, with range [0, infinity)
149  * @param landmarks The resulting locations of the landmarks
150  * @return True, if succeeded
151  * @see findBorderLandmarks8BitPerChannel().
152  */
153  static bool findBorderLandmarks(const Frame& frame, const Frame& roughMask, const PixelContour& roughContour, const unsigned int extraOffset, Vectors2& landmarks);
154 
155  /**
156  * Determines fixed landmark locations around the border of an object within a frame and within a rough contour.
157  * This function uses fingerprints around a specified rough contour to identify the landmarks.
158  * @param frame The frame in which the object is visible and for which the landmarks will be determined, must be valid
159  * @param roughMask The rough 8 bit mask covering the object, with same frame dimension and pixel origin as the provided frame, must be valid
160  * @param width The width of the given frame (and mask) in pixel, with range [1, infinity)
161  * @param height The height of the given frame (and mask) in pixel, with range [1, infinity)
162  * @param framePaddingElements The number of padding elements at the end of each frame row, in elements, with range [0, infinity)
163  * @param roughMaskPaddingElements The number of padding elements at the end of each rough mask row, in elements, with range [0, infinity)
164  * @param roughContour The rough contour around the object, with ranges [0, width)x[0, height)
165  * @param extraOffset The explicit additional offset between the actual object and the final resulting contour in pixel, with range [0, infinity)
166  * @param landmarks The resulting locations of the landmarks
167  * @return True, if succeeded
168  * @tparam tChannels The number of channels the provided frame has, with range [1, infinity)
169  * @see findBorderLandmarks().
170  */
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);
173 
174  /**
175  * Adjusts the location and shape of a given contour to a set of given landmark locations.
176  * @param contour The contour which will be adjusted
177  * @param landmarks The landmarks used to adjust the contour
178  * @param adjustedContour The resulting adjusted contour
179  * @param aggressive True, to apply an aggressive adjustment; False, to apply a conservative adjustment
180  * @return True, if succeeded
181  */
182  static bool adjustContourWithLandmarks(const Vectors2& contour, const Vectors2& landmarks, Vectors2& adjustedContour, const bool aggressive = false);
183 
184  protected:
185 
186  /**
187  * Determines the similarity mask of an object visible in a frame which's visual information is not similar to the visual content around a given rough contour around the object.
188  * This function is based on a pyramid (coarse to fine) approach where the initial mask is determined on the coarsest layer and then propagated to the next finer layer afterwards.
189  * @param frame The frame for which the mask will be determined, must be valid
190  * @param roughMask The already known very rough 8 bit mask covering the object, with frame dimension and pixel origin as the provided frame, must be valid
191  * @param roughContour The rough contour around the object which will be used for the similarity comparison, with ranges [0, width)x[0, height)
192  * @param variances The channel-wise maximal square distances between visual information of the frame and the fingerprints distributed around the rough contour so that a visual information counts as similar
193  * @param oneObject True, to receive a resulting mask composed of one large mask block (the largest block that can be determined); False, to receive a resulting mask which may be composed of several not joined blocks
194  * @param layers The number of pyramid layers to be used for the mask determination, with range [0, infinity)
195  * @param fineMaskResult The resulting fine mask for the finest pyramid layer (for the given frame)
196  * @param worker Optional worker object to distribute the computation
197  * @tparam tChannels The number of channels the given frame holds, with range [1, infinity)
198  */
199  template <unsigned int tChannels>
200  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);
201 
202  /**
203  * Determines the similarity mask of an object visible in a frame which's visual information is not similar to the visual content around a given rough contour around the object.
204  * @param frame The frame for which the mask will be determined, must be valid
205  * @param roughMask The already known very rough 8 bit mask covering the object, with frame dimension and pixel origin as the provided frame, must be valid
206  * @param fineMask The resulting precise 8 bit mask covering the object, with frame dimension and pixel origin as the provided frame, must be valid
207  * @param width The width of the provided frame (and both mask frames) in pixel, with range [1, infinity)
208  * @param height The height of the provided frame (and both mask frames) in pixel, with range [1, infinity)
209  * @param framePaddingElements The number of padding elements after each frame row, in elements, with range [0, infinity)
210  * @param roughMaskPaddingElements The number of padding elements after each rough mask row, in elements, with range [0, infinity)
211  * @param fineMaskPaddingElements The number of padding elements after each fine mask row, in elements, with range [0, infinity)
212  * @param roughContour The rough contour around the object which will be used for the similarity comparison, with ranges [0, width)x[0, height)
213  * @param variances The channel-wise maximal square distances between visual information of the frame and the fingerprints distributed around the rough contour so that a visual information counts as similar
214  * @param worker Optional worker object to distribute the computation
215  * @tparam tChannels The number of channels the given frame holds, with range [1, infinity)
216  */
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);
219 
220  /**
221  * Finetunes specific locations in a mask (e.g., for pixels at the mask's border) currently rated as mask pixels in the rough mask.
222  * This function uses fingerprints (located at the pixel positions of the rough contour) for finetuning.
223  * @param frame The frame which will be compared with the fingerprints, must be valid
224  * @param mask The already known rough mask that will be tuned (matching with the given frame), with same frame dimension and pixel origin as the given frame, must be valid
225  * @param width The width of the given frame (and both masks) in pixel, with range [1, infinity)
226  * @param height The height of the given frame (and both masks) in pixel, with range [1, infinity)
227  * @param framePaddingElements The number of padding elements at the end of each frame row, in elements, with range [0, infinity)
228  * @param maskPaddingElements The number of padding elements at the end of each mask row, in elements, with range [0, infinity)
229  * @param roughContour The rough (but distinct) contour around the rough mask which's pixel locations define the locations for the fingerprints to be used for finetuning, with ranges [0, width)x[0, height)
230  * @param positions The specific locations in the mask for which the finetuning will be done, with ranges [0, width)x[0, height)
231  * @param variances The maximal channel-based square distances between a fingerprint and an image information so that the visual content counts as similar
232  * @param worker Optional worker object to distribute the computation
233  * @tparam tChannels The number of data channels of the provided frame, with range [1, infinity)
234  */
235  template <unsigned int tChannels>
236  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);
237 
238  /**
239  * Determines the similarity mask of an object visible in a subset of a frame which's visual information is not similar to the visual content around a given rough contour around the object.
240  * @param frame The frame for which the mask will be determined, must be valid
241  * @param roughMask The already known very rough 8 bit mask covering the object, with frame dimension and pixel origin as the provided frame, must be valid
242  * @param fineMask The resulting precise 8 bit mask covering the object, with frame dimension and pixel origin as the provided frame, must be valid
243  * @param width The width of the provided frame (and both mask frames) in pixel, with range [1, infinity)
244  * @param height The height of the provided frame (and both mask frames) in pixel, with range [1, infinity)
245  * @param frameStrideElements The number of elements between two frame rows, in elements, with range [width * tChannels, infinity)
246  * @param roughMaskStrideElements The number of elements between two rough mask rows, in elements, with range [width, infinity)
247  * @param fineMaskStrideElements The number of elements between two fine mask rows, in elements, with range [width, infinity)
248  * @param fingerprints The fingerprints distributed around the object which will be used for similarity comparison
249  * @param numberFingerprints The number of provided fingerprints, with range [1, infinity)
250  * @param variances The channel-wise maximal square distances between visual information of the frame and the fingerprints distributed around the rough contour so that a visual information counts as similar
251  * @param firstColumn The first frame column to be handled allowing to shrink the area of application to improve the execution time, with range [0, width)
252  * @param numberColumns The number of columns to be handled, with range [1, width]
253  * @param firstRow The first row to be handled, with range [0, height)
254  * @param numberRows The number of rows to be handled, with range [1, height]
255  * @tparam tChannels The number of channels the given frame holds, with range [1, infinity)
256  */
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);
259 
260  /**
261  * Finetunes a subset of specific locations in a mask (e.g., for pixels at the mask's border) currently rated as mask pixels in the rough mask.
262  * This function uses fingerprints (located at the pixel positions of the rough contour) for finetuning.
263  * @param frame The frame which will be compared with the fingerprints, must be valid
264  * @param mask The already known rough mask that will be tuned (matching with the given frame), with same frame dimension and pixel origin as the given frame, must be valid
265  * @param frameStrideElements The number of elements between two frame rows, in elements, with range [width * tChannels, infinity)
266  * @param maskStrideElements The number of elements between two mask rows, in elements, with range [width, infinity)
267  * @param fingerprints The fingerprints distributed around the object which will be used for similarity comparison
268  * @param numberFingerprints The number of provided fingerprints, with range [1, infinity)
269  * @param variances The maximal channel-based square distances between a fingerprint and an image information so that the visual content counts as similar
270  * @param positions The specific locations in the mask for which the finetuning will be done, with ranges [0, width)x[0, height)
271  * @param firstPosition The first position to be handled, with range [0, positions.size())
272  * @param numberPositions The number of positions to be handled, with range [1, positions.size()]
273  * @tparam tChannels The number of data channels of the provided frame, with range [1, infinity)
274  */
275  template <unsigned int tChannels>
276  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);
277 };
278 
279 template <unsigned int tChannels>
280 inline ContourFinder::Fingerprint<tChannels>::Fingerprint(const uint8_t* const frame, const unsigned int frameStrideElements, const PixelPosition& fingerprintLocation)
281 {
282  ocean_assert(frame != nullptr);
283  ocean_assert(fingerprintLocation.x() < frameStrideElements); // we avoid to test location.y() < height);
284 
285  data_ = *(const Type*)(frame + fingerprintLocation.y() * frameStrideElements + fingerprintLocation.x() * tChannels);
286 }
287 
288 template <unsigned int tChannels>
289 inline bool ContourFinder::Fingerprint<tChannels>::isSimilar(const uint8_t* const frame, const unsigned int frameStrideElements, const PixelPosition& position, const unsigned int maximalSqrDistances[tChannels]) const
290 {
291  ocean_assert(frame != nullptr && frameStrideElements != 0u && maximalSqrDistances);
292  ocean_assert(position.x() < frameStrideElements); // we avoid to test: position.y() < height
293 
294  const uint8_t* const fingerprint = (uint8_t*)(&data_);
295  const uint8_t* const frameData = frame + position.y() + frameStrideElements + position.x() * tChannels;
296 
297  // we simply determine the square distance between each fingerprint and frame channel and measure whether the value is below the specified thresholds
298 
299  for (unsigned int n = 0u; n < tChannels; ++n)
300  {
301  if (sqrDistance(fingerprint[n], frameData[n]) > maximalSqrDistances[n])
302  {
303  return false;
304  }
305  }
306 
307  return true;
308 }
309 
310 template <unsigned int tChannels>
311 inline bool ContourFinder::Fingerprint<tChannels>::isSimilar(const uint8_t* const frameLocation, const unsigned int maximalSqrDistances[tChannels]) const
312 {
313  ocean_assert(frameLocation && maximalSqrDistances);
314 
315  const uint8_t* const fingerprint = (uint8_t*)(&data_);
316 
317  // we simply determine the square distance between each fingerprint and frame channel and measure whether the value is below the specified thresholds
318 
319  for (unsigned int n = 0u; n < tChannels; ++n)
320  {
321  if (sqrDistance(fingerprint[n], frameLocation[n]) > maximalSqrDistances[n])
322  {
323  return false;
324  }
325  }
326 
327  return true;
328 }
329 
330 template <unsigned int tChannels>
332 {
333  return data_;
334 }
335 
336 template <unsigned int tChannels>
337 inline uint8_t ContourFinder::Fingerprint<tChannels>::operator[](const unsigned int index) const
338 {
339  ocean_assert(index < tChannels);
340 
341  return ((const uint8_t*)(&data_))[index];
342 }
343 
344 }
345 
346 }
347 
348 }
349 
350 #endif // META_OCEAN_CV_SEGMENTATION_CONTOUR_FINDER_H
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:1760
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