8 #ifndef META_OCEAN_CV_FRAME_SHRINKER_H
9 #define META_OCEAN_CV_FRAME_SHRINKER_H
40 typedef void (*DownsampleBlockByTwo8BitPerChannelFunction)(
const uint8_t*
const sourceRow0,
const uint8_t*
const sourceRow1, uint8_t*
const target);
49 typedef void (*DownsampleBlockByTwoBinary8BitPerChannelFunction)(
const uint8_t*
const sourceRow0,
const uint8_t*
const sourceRow1, uint8_t*
const target,
const uint16_t threshold);
113 static inline bool downsampleByTwo11(
Frame& frame,
Worker* worker =
nullptr);
122 static inline bool downsampleBinayMaskByTwo11(
Frame& mask,
const unsigned int threshold = 766u,
Worker* worker =
nullptr);
140 static inline bool downsampleByTwo14641(
Frame& frame,
Worker* worker =
nullptr);
152 static bool pyramidByTwo11(
const Frame& source, uint8_t*
const pyramidTarget,
const size_t pyramidTargetSize,
const unsigned int layers,
const bool copyFirstLayer,
Worker* worker);
169 static bool pyramidByTwo8BitPerChannel11(
const uint8_t* source, uint8_t* pyramidTarget,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int channels,
const size_t pyramidTargetSize,
const unsigned int layers,
const unsigned int sourcePaddingElements,
const bool copyFirstLayer,
Worker* worker);
190 static inline void downsampleByTwo8BitPerChannel11(
const uint8_t* source, uint8_t* target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
203 static inline void downsampleBinayMaskByTwo8BitPerChannel11(
const uint8_t* source, uint8_t* target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int threshold = 766u,
Worker* worker =
nullptr);
227 static inline void downsampleByTwo8BitPerChannel14641(
const uint8_t*
const source, uint8_t*
const target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
246 static bool pyramidByTwo8BitPerChannel11WithThreads(
const uint8_t* source, uint8_t* pyramidTarget,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int channels,
const size_t pyramidTargetSize,
const unsigned int layers,
const bool copyFirstLayer,
const unsigned int sourcePaddingElements,
const unsigned int threads,
Worker* worker);
264 static void pyramidByTwo8BitPerChannel11WithThreadsSubset(
const uint8_t* source, uint8_t* pyramidTarget,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int channels,
const size_t pyramidTargetSize,
const unsigned int layers,
const bool copyFirstLayer,
const unsigned int sourcePaddingElements,
const unsigned int firstSubsetsSourceHeight,
const unsigned int subsets,
const unsigned int subsetIndex,
const unsigned int valueOne);
278 static void downsampleByTwo8BitPerChannel11Subset(
const uint8_t* source, uint8_t* target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows);
292 static void downsampleBinayMaskByTwo8BitPerChannel11Subset(
const uint8_t* source, uint8_t* target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int threshold,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows);
324 OCEAN_PREVENT_INLINE
static void downsampleByTwoThreeRows8BitPerChannel121(
const uint8_t* source, uint8_t* target,
const unsigned int sourceWidth,
const unsigned int channels,
const unsigned int sourceStrideElements);
337 static void downsampleByTwoRowVertical8BitPerChannel14641(
const uint8_t*
const source, uint16_t* targetRow,
const unsigned int sourceElements,
const unsigned int sourceHeight,
const unsigned int sourceStrideElements,
const unsigned int ySource);
351 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
368 #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
394 template <
unsigned int tChannels>
413 static void downsampleByTwo8BitPerChannel14641Subset(
const uint8_t* source, uint8_t* target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int targetWidth,
const unsigned int channels,
const unsigned int sourceStrideElements,
const unsigned int targetStrideElements,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows);
426 static inline unsigned int mirroredBorderLocationLeft(
const int value);
441 static inline unsigned int mirroredBorderLocationRight(
const unsigned int value,
const unsigned int size);
455 frame = std::move(tmpFrame);
470 mask = std::move(tmpMask);
485 frame = std::move(tmpFrame);
491 ocean_assert(source !=
nullptr && target !=
nullptr);
492 ocean_assert(sourceWidth >= 2u && sourceHeight >= 2u);
493 ocean_assert(threshold <= 255 * 4u);
495 const unsigned int targetHeight = sourceHeight / 2u;
496 ocean_assert(targetHeight > 0u);
500 worker->
executeFunction(
Worker::Function::createStatic(&
downsampleBinayMaskByTwo8BitPerChannel11Subset, source, target, sourceWidth, sourceHeight, sourcePaddingElements, targetPaddingElements, threshold, 0u, 0u), 0u, targetHeight, 7u, 8u, 20u);
508 inline void FrameShrinker::downsampleByTwo8BitPerChannel11(
const uint8_t* source, uint8_t* target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker)
510 ocean_assert(source !=
nullptr && target !=
nullptr);
511 ocean_assert(sourceWidth >= 2u && sourceHeight >= 1u);
512 ocean_assert(channels >= 1u);
514 const unsigned int targetHeight = sourceHeight / 2u;
518 worker->
executeFunction(
Worker::Function::createStatic(
FrameShrinker::downsampleByTwo8BitPerChannel11Subset, source, target, sourceWidth, sourceHeight, channels, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, targetHeight);
544 ocean_assert(value < 2u * size);
556 ocean_assert(size * 2u - value - 1u < size);
557 return size * 2u - value - 1u;
561 inline void FrameShrinker::downsampleByTwo8BitPerChannel14641(
const uint8_t*
const source, uint8_t*
const target,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker)
563 ocean_assert(source !=
nullptr && target !=
nullptr);
564 ocean_assert(sourceWidth >= 2u && sourceHeight >= 2u);
565 ocean_assert((sourceWidth + 0u) / 2u == targetWidth || (sourceWidth + 1u) / 2u == targetWidth);
566 ocean_assert((sourceHeight + 0u) / 2u == targetHeight || (sourceHeight + 1u) / 2u == targetHeight);
567 ocean_assert(channels != 0u);
569 const unsigned int sourceStrideElements = sourceWidth * channels + sourcePaddingElements;
570 const unsigned int targetStrideElements = targetWidth * channels + targetPaddingElements;
574 worker->
executeFunction(
Worker::Function::createStatic(
downsampleByTwo8BitPerChannel14641Subset, source, target, sourceWidth, sourceHeight, targetWidth, channels, sourceStrideElements, targetStrideElements, 0u, 0u), 0u, targetHeight);
This class implements function to downsize a frame.
Definition: FrameShrinker.h:31
static void downsampleBinayMaskByTwo8BitPerChannel11Subset(const uint8_t *source, uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int threshold, const unsigned int firstTargetRow, const unsigned int numberTargetRows)
Reduces the resolution of a given binary frame with 8bit per pixel with values 0 and 255 by two,...
static void downsampleByTwoRowVertical8BitPerChannel14641(const uint8_t *const source, uint16_t *targetRow, const unsigned int sourceElements, const unsigned int sourceHeight, const unsigned int sourceStrideElements, const unsigned int ySource)
Applies a vertical 14641 filter to each pixel in a given row not applying any SIMD instructions.
static bool pyramidByTwo8BitPerChannel11(const uint8_t *source, uint8_t *pyramidTarget, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int channels, const size_t pyramidTargetSize, const unsigned int layers, const unsigned int sourcePaddingElements, const bool copyFirstLayer, Worker *worker)
Fills the buffer of a pyramid frame for frames with 1 plane and data type DT_UNSIGNED_INTEGER_8 apply...
static void downsampleByTwoRowVertical8BitPerChannel14641SSE(const uint8_t *const source, uint16_t *targetRow, const unsigned int sourceElements, const unsigned int sourceHeight, const unsigned int sourceStrideElements, const unsigned int ySource)
Applies a vertical 14641 filter to each pixel in a given row using SSE instructions.
static void downsampleBinayMaskByTwo8BitPerChannel11(const uint8_t *source, uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int threshold=766u, Worker *worker=nullptr)
Reduces the resolution of a given binary frame with 8bit per pixel with values 0 and 255 by two,...
Definition: FrameShrinker.h:489
static bool pyramidByTwo8BitPerChannel11WithThreads(const uint8_t *source, uint8_t *pyramidTarget, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int channels, const size_t pyramidTargetSize, const unsigned int layers, const bool copyFirstLayer, const unsigned int sourcePaddingElements, const unsigned int threads, Worker *worker)
Fills the buffer of a pyramid frame for frames with 1 plane and data type DT_UNSIGNED_INTEGER_8.
static void downsampleByTwo8BitPerChannel11(const uint8_t *source, uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Reduces the resolution of a given frame by two, applying a 1-1 downsampling.
Definition: FrameShrinker.h:508
static void downsampleByTwo8BitPerChannel11Subset(const uint8_t *source, uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstTargetRow, const unsigned int numberTargetRows)
Reduces the resolution of a given frame by two.
static OCEAN_PREVENT_INLINE void downsampleByTwoThreeRows8BitPerChannel121(const uint8_t *source, uint8_t *target, const unsigned int sourceWidth, const unsigned int channels, const unsigned int sourceStrideElements)
Downsamples three rows to one row in a frame, applying a 2x3 [1-2-1, 1-2-1] down sampling filter.
static void downsampleByTwo8BitPerChannel14641(const uint8_t *const source, uint8_t *const target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Reduces the resolution of a given frame by two, applying a 1-4-6-4-1 downsampling.
Definition: FrameShrinker.h:561
static void downsampleByTwoRowHorizontal8BitPerChannel14641(const uint16_t *sourceRow, uint8_t *targetRow, const unsigned int targetWidth, const unsigned int channels)
Applies a horizontal 14641 filter to each second pixel in a given row not applying any SIMD instructi...
static void pyramidByTwo8BitPerChannel11WithThreadsSubset(const uint8_t *source, uint8_t *pyramidTarget, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int channels, const size_t pyramidTargetSize, const unsigned int layers, const bool copyFirstLayer, const unsigned int sourcePaddingElements, const unsigned int firstSubsetsSourceHeight, const unsigned int subsets, const unsigned int subsetIndex, const unsigned int valueOne)
Fills a subset of the buffer of a pyramid frame for a given frame with 1 plane and data type DT_UNSIG...
static bool downsampleByTwo11(const Frame &source, Frame &target, Worker *worker=nullptr)
Reduces the resolution of a given frame by two, applying a 1-1 downsampling.
static OCEAN_PREVENT_INLINE void downsampleByTwoOneRowThreeColumns8BitPerChannel121(const uint8_t *source, uint8_t *target, const unsigned int channels, const unsigned int sourceStrideElements)
Downsamples an area of 2x3 pixels (two rows and three columns) to one pixel in a frame,...
static bool pyramidByTwo11(const Frame &source, uint8_t *const pyramidTarget, const size_t pyramidTargetSize, const unsigned int layers, const bool copyFirstLayer, Worker *worker)
Fills the buffer of a pyramid frame for frames with 1 plane and data type DT_UNSIGNED_INTEGER_8.
static bool downsampleBinayMaskByTwo11(const Frame &source, Frame &target, const unsigned int threshold=766u, Worker *worker=nullptr)
Reduces the resolution of a given binary mask by two, applying a 1-1 downsampling.
static void downsampleByTwoRowVertical8BitPerChannel14641NEON(const uint8_t *const source, uint16_t *targetRow, const unsigned int sourceElements, const unsigned int sourceHeight, const unsigned int sourceStrideElements, const unsigned int ySource)
Applies a vertical 14641 filter to each pixel in a given row using NEON instructions.
static void downsampleByTwoRowHorizontal8BitPerChannel14641NEON(const uint16_t *sourceRow, uint8_t *targetRow, const unsigned int targetWidth, const unsigned int channels)
Applies a horizontal 14641 filter to each second pixel in a given row applying NEON instructions.
static void downsampleByTwo8BitPerChannel14641Subset(const uint8_t *source, uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int channels, const unsigned int sourceStrideElements, const unsigned int targetStrideElements, const unsigned int firstTargetRow, const unsigned int numberTargetRows)
Reduces the resolution in a subregion of a given frame by two, taking 5x5 (= 25) pixel values into ac...
static bool downsampleByTwo14641(const Frame &source, Frame &target, Worker *worker=nullptr)
Reduces the resolution of a given frame by two, applying a 1-4-6-4-1 downsampling.
static void determineFunctionDownsampleBlockByTwo8Bit11(const unsigned int sourceWidth, const unsigned int channels, DownsampleBlockByTwo8BitPerChannelFunction &downsampleBlockFunction, unsigned int &sourceElementsPerBlock)
Determines the function to down sample a block of pixel elements by two with a 11 filter pattern.
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a static function with no function parameter.
Definition: Caller.h:2876
This class implements Ocean's image class.
Definition: Frame.h:1792
void setRelativeTimestamp(const Timestamp &relative)
Sets the relative timestamp of this frame.
Definition: Frame.h:4153
void setTimestamp(const Timestamp ×tamp)
Sets the timestamp of this frame.
Definition: Frame.h:4148
const Timestamp & timestamp() const
Returns the timestamp of this frame.
Definition: Frame.h:4138
const Timestamp & relativeTimestamp() const
Returns the relative timestamp of this frame.
Definition: Frame.h:4143
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
static unsigned int mirroredBorderLocationRight(const unsigned int value, const unsigned int size)
Mirrors a given value at the right border if necessary.
Definition: FrameShrinker.h:542
static unsigned int mirroredBorderLocationLeft(const int value)
Mirrors a given value at the left border if necessary.
Definition: FrameShrinker.h:526
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15