8 #ifndef META_OCEAN_CV_SYNTHESIS_MAPPING_I_H
9 #define META_OCEAN_CV_SYNTHESIS_MAPPING_I_H
46 inline const PixelPosition& position(
const unsigned int x,
const unsigned int y)
const;
54 inline PixelPosition& position(
const unsigned int x,
const unsigned int y);
76 inline void setPosition(
const unsigned int x,
const unsigned int y,
const PixelPosition& pixelPosition);
134 inline MappingI(
const unsigned int width,
const unsigned int height);
151 template <
unsigned int tChannels,
unsigned int tBorderFactor>
152 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);
175 Mapping(pixelMapping.width_, pixelMapping.height_),
190 Mapping(std::move(pixelMapping)),
193 mappingI_ = pixelMapping.mappingI_;
194 pixelMapping.mappingI_ =
nullptr;
273 template <
unsigned int tChannels,
unsigned int tBorderFactor>
274 inline 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)
276 static_assert(tBorderFactor >= 1u,
"Invalid border factor!");
278 ocean_assert(frame0 !=
nullptr && frame1 !=
nullptr && mask0 !=
nullptr);
279 ocean_assert(width0 >= 5u && width1 >= 5u);
281 const unsigned int frame0StrideElements = width0 * tChannels + frame0PaddingElements;
282 const unsigned int frame1StrideElements = width1 * tChannels + frame1PaddingElements;
283 const unsigned int mask0StrideElements = width0 + mask0PaddingElements;
285 unsigned int ssd = 0u;
287 for (
unsigned int y = 0u; y < 5u; ++y)
289 for (
unsigned int x = 0u; x < 5u; ++x)
291 if (x == 2u && y == 2u)
297 unsigned int local = 0u;
299 for (
unsigned int n = 0u; n < tChannels; ++n)
301 const int value = int(frame0[x * tChannels + n] - frame1[x * tChannels + n]);
302 local += value * value;
305 if (mask0[x] == 0xFFu)
307 local *= tBorderFactor;
313 frame0 += frame0StrideElements;
314 frame1 += frame1StrideElements;
315 mask0 += mask0StrideElements;
323 if (
this != &pixelMapping)
349 if (
this != &pixelMapping)
353 mappingI_ = pixelMapping.mappingI_;
354 pixelMapping.mappingI_ =
nullptr;
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
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:407
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:30
MappingI & operator=(const MappingI &pixelMapping)
Assign operator.
Definition: MappingI.h:321
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:274
const PixelPosition * row(const unsigned int y) const
Returns the pointer to a mapping row.
Definition: MappingI.h:243
const PixelPosition * operator()() const
Returns the mappings of this object.
Definition: MappingI.h:263
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:215
void reset()
Resets the stored mapping.
Definition: MappingI.h:257
PixelPosition * mappingI_
Pixel mappings for each pixel.
Definition: MappingI.h:171
void setPosition(const unsigned int x, const unsigned int y, const PixelPosition &pixelPosition)
Sets a new mapping for a specified position.
Definition: MappingI.h:237
~MappingI() override
Destructs a mapping object.
Definition: MappingI.h:210
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15