8#ifndef META_OCEAN_CV_SYNTHESIS_MAPPING_I_H
9#define META_OCEAN_CV_SYNTHESIS_MAPPING_I_H
49 inline const PixelPosition& position(
const unsigned int x,
const unsigned int y)
const;
57 inline PixelPosition& position(
const unsigned int x,
const unsigned int y);
79 inline void setPosition(
const unsigned int x,
const unsigned int y,
const PixelPosition& pixelPosition);
137 inline MappingI(
const unsigned int width,
const unsigned int height);
154 template <
unsigned int tChannels,
unsigned int tBorderFactor>
155 static inline unsigned int ssd5x5MaskNoCenter(
const uint8_t* frame0,
const uint8_t* frame1,
const uint8_t* mask0,
const unsigned int width0,
const unsigned int width1,
const unsigned int frame0PaddingElements,
const unsigned int frame1PaddingElements,
const unsigned int mask0PaddingElements);
178 Mapping(pixelMapping.width_, pixelMapping.height_),
193 Mapping(std::move(pixelMapping)),
196 mappingI_ = pixelMapping.mappingI_;
197 pixelMapping.mappingI_ =
nullptr;
276template <
unsigned int tChannels,
unsigned int tBorderFactor>
277inline unsigned int MappingI::ssd5x5MaskNoCenter(
const uint8_t* frame0,
const uint8_t* frame1,
const uint8_t* mask0,
const unsigned int width0,
const unsigned int width1,
const unsigned int frame0PaddingElements,
const unsigned int frame1PaddingElements,
const unsigned int mask0PaddingElements)
279 static_assert(tBorderFactor >= 1u,
"Invalid border factor!");
281 ocean_assert(frame0 !=
nullptr && frame1 !=
nullptr && mask0 !=
nullptr);
282 ocean_assert(width0 >= 5u && width1 >= 5u);
284 const unsigned int frame0StrideElements = width0 * tChannels + frame0PaddingElements;
285 const unsigned int frame1StrideElements = width1 * tChannels + frame1PaddingElements;
286 const unsigned int mask0StrideElements = width0 + mask0PaddingElements;
288 unsigned int ssd = 0u;
290 for (
unsigned int y = 0u; y < 5u; ++y)
292 for (
unsigned int x = 0u; x < 5u; ++x)
294 if (x == 2u && y == 2u)
300 unsigned int local = 0u;
302 for (
unsigned int n = 0u; n < tChannels; ++n)
304 const int value = int(frame0[x * tChannels + n] - frame1[x * tChannels + n]);
305 local += value * value;
308 if (mask0[x] == 0xFFu)
310 local *= tBorderFactor;
316 frame0 += frame0StrideElements;
317 frame1 += frame1StrideElements;
318 mask0 += mask0StrideElements;
326 if (
this != &pixelMapping)
352 if (
this != &pixelMapping)
356 mappingI_ = pixelMapping.mappingI_;
357 pixelMapping.mappingI_ =
nullptr;
T y() const
Returns the vertical coordinate position of this object.
Definition PixelPosition.h:468
T x() const
Returns the horizontal coordinate position of this object.
Definition PixelPosition.h:456
Cost function:
Definition MappingF1.h:52
This class is the base class for all mappings.
Definition Mapping.h:35
unsigned int width_
Width of this pixel mapping object in pixel.
Definition Mapping.h:147
unsigned int width() const
Returns the width of this mapping object.
Definition Mapping.h:282
Mapping & operator=(const Mapping &mapping)
Assign operator.
Definition Mapping.h:411
unsigned int height_
Height of this pixel mapping object in pixel.
Definition Mapping.h:150
unsigned int height() const
Returns the height of this mapping object.
Definition Mapping.h:287
This class implements a mapping with integer accuracy.
Definition MappingI.h:33
MappingI & operator=(const MappingI &pixelMapping)
Assign operator.
Definition MappingI.h:324
static unsigned int ssd5x5MaskNoCenter(const uint8_t *frame0, const uint8_t *frame1, const uint8_t *mask0, const unsigned int width0, const unsigned int width1, const unsigned int frame0PaddingElements, const unsigned int frame1PaddingElements, const unsigned int mask0PaddingElements)
Calculates the sum of square differences between two 5x5 frame regions in two frames with explicit we...
Definition MappingI.h:277
const PixelPosition * row(const unsigned int y) const
Returns the pointer to a mapping row.
Definition MappingI.h:246
const PixelPosition * operator()() const
Returns the mappings of this object.
Definition MappingI.h:266
MappingI()=default
Creates an empty mapping object.
const PixelPosition & position(const unsigned int x, const unsigned int y) const
Returns the mapping for a given position.
Definition MappingI.h:218
void reset()
Resets the stored mapping.
Definition MappingI.h:260
PixelPosition * mappingI_
Pixel mappings for each pixel.
Definition MappingI.h:174
void setPosition(const unsigned int x, const unsigned int y, const PixelPosition &pixelPosition)
Sets a new mapping for a specified position.
Definition MappingI.h:240
~MappingI() override
Destructs a mapping object.
Definition MappingI.h:213
PixelPositionT< unsigned int > PixelPosition
Definition of the default PixelPosition object with a data type allowing only positive coordinate val...
Definition PixelPosition.h:32
The namespace covering the entire Ocean framework.
Definition Accessor.h:15