8 #ifndef META_OCEAN_CV_FRAME_MEAN_H
9 #define META_OCEAN_CV_FRAME_MEAN_H
45 template <
typename T,
typename TMean,
unsigned int tChannels>
46 static void meanValue(
const T* frame,
const unsigned int width,
const unsigned int height, TMean* meanValues,
const unsigned int framePaddingElements,
Worker* worker =
nullptr);
76 template <
unsigned int tChannels>
92 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
93 static inline void addToFrame(
const TSource*
const source, TTarget*
const target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
123 template <
unsigned int tChannels>
124 static inline void addToFrameIndividually8BitPerChannel(
const uint8_t* source,
const uint8_t* mask,
unsigned int* target,
unsigned int* denominators,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int maskPaddingElements,
const unsigned int targetPaddingElements,
const unsigned int denominatorsPaddingElements,
const uint8_t nonMaskValue,
Worker* worker =
nullptr);
135 template <
unsigned int tChannels>
136 static inline void addToFrameIndividually8BitPerChannel(
const uint8_t* source,
unsigned int* targetWithDenominator,
const unsigned int width,
const unsigned int height,
Worker* worker =
nullptr);
148 template <
unsigned int tChannels>
149 static inline void addToFrameIndividually8BitPerChannel(
const uint8_t* source,
const uint8_t* mask,
unsigned int* targetWithDenominator,
const unsigned int width,
const unsigned int height,
Worker* worker =
nullptr);
165 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
166 static inline void normalizeFrame(
const TSource*
const source, TTarget*
const target,
const TSource denominator,
unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
180 template <
unsigned int tChannels>
181 static inline void normalizeFrameIndividually8BitPerChannel(
const unsigned int* source,
const unsigned int* denominators, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t* zeroValue =
nullptr,
Worker* worker =
nullptr);
193 template <
unsigned int tChannels>
194 static inline void normalizeFrameIndividually8BitPerChannel(
const unsigned int* sourceWithDenominator, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t* zeroValue,
Worker* worker =
nullptr);
211 template <
typename T,
typename TSum,
unsigned int tChannels>
212 static void sumFrameSubset(
const T* frame,
const unsigned int width, TSum* sumValues,
Lock* lock,
const unsigned int framePaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
228 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
229 static void addToFrameSubset(
const TSource*
const source, TTarget*
const target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
248 template <
unsigned int tChannels>
249 static void addToFrameIndividuallyBlock8BitPerChannelSubset(
const uint8_t* source,
const uint8_t* mask,
unsigned int* target,
unsigned int* denominators,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int maskPaddingElements,
const unsigned int targetPaddingElements,
const unsigned int denominatorsPaddingElements,
const uint8_t nonMaskValue,
const unsigned int firstRow,
const unsigned int numberRows);
261 template <
unsigned int tChannels>
262 static void addToFrameIndividuallyZipped8BitPerChannelSubset(
const uint8_t* source,
unsigned int* targetWithDenominator,
const unsigned int width,
const unsigned int height,
const unsigned int firstRow,
const unsigned int numberRows);
275 template <
unsigned int tChannels>
276 static void addToFrameIndividuallyZipped8BitPerChannelSubset(
const uint8_t* source,
const uint8_t* mask,
unsigned int* targetWithDenominator,
const unsigned int width,
const unsigned int height,
const unsigned int firstRow,
const unsigned int numberRows);
293 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
294 static void normalizeFrameSubset(
const TSource*
const source, TTarget*
const target,
const TSource denominator,
unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
308 template <
unsigned int tChannels>
309 static void normalizeFrameIndividually8BitPerChannelSubset(
const unsigned int* source,
const unsigned int* denominators, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t* zeroValue,
const unsigned int firstRow,
const unsigned int numberRows);
322 template <
unsigned int tChannels>
323 static void normalizeFrameIndividually8BitPerChannelSubset(
const unsigned int* sourceWithDenominator, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t* zeroValue,
const unsigned int firstRow,
const unsigned int numberRows);
326 template <
typename T,
typename TMean,
unsigned int tChannels>
327 void FrameMean::meanValue(
const T* frame,
const unsigned int width,
const unsigned int height, TMean* meanValues,
const unsigned int framePaddingElements,
Worker* worker)
329 static_assert(tChannels > 0u,
"Invalid channel number!");
331 ocean_assert(frame !=
nullptr && meanValues !=
nullptr);
332 ocean_assert(width > 0u && height > 0u);
336 TSum sumValues[tChannels];
337 for (
unsigned int n = 0u; n < tChannels; ++n)
339 sumValues[n] = TSum(0);
345 worker->
executeFunction(
Worker::Function::createStatic(sumFrameSubset<T, TSum, tChannels>, frame, width, sumValues, &lock, framePaddingElements, 0u, 0u), 0u, height, 5u, 6u, 40u);
349 sumFrameSubset<T, TSum, tChannels>(frame, width, sumValues,
nullptr, framePaddingElements, 0u, height);
352 const unsigned int pixels = width * height;
354 for (
unsigned int n = 0u; n < tChannels; ++n)
359 if constexpr (std::is_same<float, TMean>::value || std::is_same<double, TMean>::value)
361 meanValues[n] = TMean(
double(sumValues[n]) /
double(pixels));
365 meanValues[n] = TMean((sumValues[n] + TSum(pixels) / TSum(2)) / TSum(pixels));
370 template <
unsigned int tChannels>
373 static_assert(tChannels >= 1u,
"Invalid channel number!");
376 ocean_assert(firstFrameIndex <= lastFrameIndex);
381 ocean_assert(sourceFrameType.
isValid());
384 ocean_assert(lastFrameIndex < interfaceNumberFrames);
386 const unsigned int meanFrames = lastFrameIndex - firstFrameIndex + 1u;
387 ocean_assert(meanFrames >= 1u && meanFrames < 16843010u);
389 const unsigned int width = sourceFrameType.
width();
390 const unsigned int height = sourceFrameType.
height();
392 const FrameType targetFrameType(sourceFrameType, targetPixelFormat);
394 ocean_assert(width > 0u && height > 0u);
395 if (width == 0u || height == 0u || meanFrames >= 16843010u || interfaceNumberFrames <= lastFrameIndex)
403 for (
unsigned int n = firstFrameIndex; n <= lastFrameIndex; ++n)
407 if (n + 1u <= lastFrameIndex)
412 if (frame.
isNull() || !frame->isValid())
427 Frame result(targetFrameType);
434 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
435 inline void FrameMean::addToFrame(
const TSource*
const source, TTarget*
const target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker)
437 static_assert(
sizeof(TSource) <=
sizeof(TTarget),
"Invalid data type!");
438 static_assert(tChannels >= 1u,
"Invalid channel number!");
440 ocean_assert(source !=
nullptr && target !=
nullptr);
441 ocean_assert(width != 0u && height != 0u);
445 worker->
executeFunction(
Worker::Function::createStatic(&FrameMean::addToFrameSubset<TSource, TTarget, tChannels>, source, target, width, height, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height);
449 addToFrameSubset<TSource, TTarget, tChannels>(source, target, width, height, sourcePaddingElements, targetPaddingElements, 0u, height);
453 template <
unsigned int tChannels>
454 inline void FrameMean::addToFrameIndividually8BitPerChannel(
const uint8_t* source,
const uint8_t* mask,
unsigned int* target,
unsigned int* denominators,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int maskPaddingElements,
const unsigned int targetPaddingElements,
const unsigned int denominatorsPaddingElements,
const uint8_t nonMaskValue,
Worker* worker)
456 static_assert(tChannels >= 1u,
"Invalid channel number!");
458 ocean_assert(source && mask && target && denominators);
459 ocean_assert(width != 0u && height != 0u);
463 worker->
executeFunction(
Worker::Function::createStatic(&FrameMean::addToFrameIndividuallyBlock8BitPerChannelSubset<tChannels>, source, mask, target, denominators, width, height, sourcePaddingElements, maskPaddingElements, targetPaddingElements, denominatorsPaddingElements, nonMaskValue, 0u, 0u), 0u, height);
467 addToFrameIndividuallyBlock8BitPerChannelSubset<tChannels>(source, mask, target, denominators, width, height, sourcePaddingElements, maskPaddingElements, targetPaddingElements, denominatorsPaddingElements, nonMaskValue, 0u, height);
471 template <
unsigned int tChannels>
474 static_assert(tChannels >= 1u,
"Invalid channel number!");
476 ocean_assert(source && mask && targetWithDenominator);
477 ocean_assert(width != 0u && height != 0u);
481 worker->
executeFunction(
Worker::Function::createStatic(&FrameMean::addToFrameIndividuallyZipped8BitPerChannelSubset<tChannels>, source, mask, targetWithDenominator, width, height, 0u, 0u), 0u, height, 5u, 6u);
485 addToFrameIndividuallyZipped8BitPerChannelSubset<tChannels>(source, mask, targetWithDenominator, width, height, 0u, height);
489 template <
unsigned int tChannels>
492 static_assert(tChannels >= 1u,
"Invalid channel number!");
494 ocean_assert(source && targetWithDenominator);
495 ocean_assert(width != 0u && height != 0u);
499 worker->
executeFunction(
Worker::Function::createStatic(&FrameMean::addToFrameIndividuallyZipped8BitPerChannelSubset<tChannels>, source, targetWithDenominator, width, height, 0u, 0u), 0u, height, 4u, 5u);
503 addToFrameIndividuallyZipped8BitPerChannelSubset<tChannels>(source, targetWithDenominator, width, height, 0u, height);
507 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
508 inline void FrameMean::normalizeFrame(
const TSource*
const source, TTarget*
const target,
const TSource denominator,
unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker)
510 static_assert(tChannels >= 1u,
"Invalid channel number!");
512 ocean_assert(source !=
nullptr && target !=
nullptr);
513 ocean_assert(width != 0u && height != 0u);
517 worker->
executeFunction(
Worker::Function::createStatic(&FrameMean::normalizeFrameSubset<TSource, TTarget, tChannels>, source, target, denominator, width, height, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height);
521 normalizeFrameSubset<TSource, TTarget, tChannels>(source, target, denominator, width, height, sourcePaddingElements, targetPaddingElements, 0u, height);
525 template <
unsigned int tChannels>
528 static_assert(tChannels >= 1u,
"Invalid channel number!");
530 ocean_assert(source && denominators && target);
531 ocean_assert(width != 0u && height != 0u);
533 const uint8_t zeroPixel[tChannels] = {0u};
537 worker->
executeFunction(
Worker::Function::createStatic(&FrameMean::normalizeFrameIndividually8BitPerChannelSubset<tChannels>, source, denominators, target, width, height, zeroValue ? zeroValue : zeroPixel, 0u, 0u), 0u, height, 6u, 7u);
541 normalizeFrameIndividually8BitPerChannelSubset<tChannels>(source, denominators, target, width, height, zeroValue ? zeroValue : zeroPixel, 0u, height);
545 template <
unsigned int tChannels>
548 static_assert(tChannels >= 1u,
"Invalid channel number!");
550 ocean_assert(sourceWithDenominator && target);
551 ocean_assert(width != 0u && height != 0u);
553 const uint8_t zeroPixel[tChannels] = {0u};
557 worker->
executeFunction(
Worker::Function::createStatic(&FrameMean::normalizeFrameIndividually8BitPerChannelSubset<tChannels>, sourceWithDenominator, target, width, height, zeroValue ? zeroValue : zeroPixel, 0u, 0u), 0u, height, 5u, 6u);
561 normalizeFrameIndividually8BitPerChannelSubset<tChannels>(sourceWithDenominator, target, width, height, zeroValue ? zeroValue : zeroPixel, 0u, height);
565 template <
typename T,
typename TSum,
unsigned int tChannels>
566 void FrameMean::sumFrameSubset(
const T* frame,
const unsigned int width, TSum* sumValues,
Lock* lock,
const unsigned int framePaddingElements,
const unsigned int firstRow,
const unsigned int numberRows)
568 static_assert(tChannels >= 1u,
"Invalid channel number!");
570 ocean_assert(frame !=
nullptr && sumValues !=
nullptr);
571 ocean_assert(width > 0u);
573 TSum localSumValues[tChannels];
575 for (
unsigned int n = 0u; n < tChannels; ++n)
577 localSumValues[n] = TSum(0);
580 const unsigned int frameStrideElements = width * tChannels + framePaddingElements;
582 frame += firstRow * frameStrideElements;
584 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
586 const T* frameRowEnd = frame + width * tChannels;
588 while (frame != frameRowEnd)
590 ocean_assert(frame < frameRowEnd);
592 for (
unsigned int n = 0u; n < tChannels; ++n)
597 if (TSum(frame[n]) > TSum(0))
607 localSumValues[n] += TSum(frame[n]);
613 frame += framePaddingElements;
618 for (
unsigned int n = 0u; n < tChannels; ++n)
620 sumValues[n] += localSumValues[n];
624 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
625 void FrameMean::addToFrameSubset(
const TSource*
const source, TTarget*
const target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows)
627 static_assert(
sizeof(TSource) <=
sizeof(TTarget),
"Invalid data type!");
628 static_assert(tChannels >= 1u,
"Invalid channel number!");
630 ocean_assert(source !=
nullptr && target !=
nullptr);
631 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
633 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
634 const unsigned int targetStrideElements = width * tChannels + targetPaddingElements;
636 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
638 const TSource*
const sourceRow = source + y * sourceStrideElements;
639 TTarget*
const targetRow = target + y * targetStrideElements;
641 for (
unsigned int n = 0u; n < width * tChannels; ++n)
643 targetRow[n] = targetRow[n] + TTarget(sourceRow[n]);
648 template <
unsigned int tChannels>
649 void FrameMean::addToFrameIndividuallyBlock8BitPerChannelSubset(
const uint8_t* source,
const uint8_t* mask,
unsigned int* target,
unsigned int* denominators,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int maskPaddingElements,
const unsigned int targetPaddingElements,
const unsigned int denominatorsPaddingElements,
const uint8_t nonMaskValue,
const unsigned int firstRow,
const unsigned int numberRows)
651 static_assert(tChannels >= 1u,
"Invalid channel number!");
653 ocean_assert(source && mask && target && denominators);
654 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
656 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
657 const unsigned int maskStrideElements = width + maskPaddingElements;
658 const unsigned int targetStrideElements = width * tChannels + targetPaddingElements;
659 const unsigned int denominatorsStrideElements = width + denominatorsPaddingElements;
661 target += firstRow * targetStrideElements;
662 denominators += firstRow * denominatorsStrideElements;
664 source += firstRow * sourceStrideElements;
665 mask += firstRow * maskStrideElements;
667 for (
unsigned int rowIndex = firstRow; rowIndex < firstRow + numberRows; ++rowIndex)
669 const uint8_t*
const sourceRowEnd = source + width * tChannels;
671 while (source != sourceRowEnd)
673 ocean_assert(source < sourceRowEnd);
675 if (*mask++ != nonMaskValue)
677 for (
unsigned int n = 0u; n < tChannels; ++n)
679 target[n] += source[n];
690 target += targetPaddingElements;
691 denominators += denominatorsPaddingElements;
693 source += sourcePaddingElements;
694 mask += maskPaddingElements;
698 template <
unsigned int tChannels>
701 static_assert(tChannels >= 1u,
"Invalid channel number!");
703 ocean_assert(source && targetWithDenominator);
704 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
706 targetWithDenominator += firstRow * width * (tChannels + 1u);
708 source += firstRow * width * tChannels;
710 const uint8_t*
const sourceEnd = source + numberRows * width * tChannels;
712 while (source != sourceEnd)
714 ocean_assert(source < sourceEnd);
716 for (
unsigned int n = 0u; n < tChannels; ++n)
717 *targetWithDenominator++ += *source++;
719 (*targetWithDenominator++)++;
723 template <
unsigned int tChannels>
726 static_assert(tChannels >= 1u,
"Invalid channel number!");
728 ocean_assert(source && mask && targetWithDenominator);
729 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
731 targetWithDenominator += firstRow * width * (tChannels + 1u);
733 source += firstRow * width * tChannels;
734 mask += firstRow * width;
736 const uint8_t*
const sourceEnd = source + numberRows * width * tChannels;
738 while (source != sourceEnd)
740 ocean_assert(source < sourceEnd);
744 for (
unsigned int n = 0u; n < tChannels; ++n)
746 targetWithDenominator[n] += source[n];
749 targetWithDenominator[tChannels]++;
752 targetWithDenominator += tChannels + 1u;
757 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
758 void FrameMean::normalizeFrameSubset(
const TSource*
const source, TTarget*
const target,
const TSource denominator,
unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows)
760 static_assert(tChannels >= 1u,
"Invalid channel number!");
762 ocean_assert(source !=
nullptr && target !=
nullptr);
763 ocean_assert(denominator != 0u);
764 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
766 const TSource denominator_2 = denominator / TSource(2);
768 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
769 const unsigned int targetStrideElements = width * tChannels + targetPaddingElements;
771 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
773 const TSource*
const sourceRow = source + y * sourceStrideElements;
774 TTarget*
const targetRow = target + y * targetStrideElements;
776 for (
unsigned int n = 0u; n < width * tChannels; ++n)
778 if (std::is_signed<TSource>::value)
780 targetRow[n] = TTarget(sourceRow[n] / denominator);
784 targetRow[n] = TTarget((sourceRow[n] + denominator_2) / denominator);
790 template <
unsigned int tChannels>
793 static_assert(tChannels >= 1u,
"Invalid channel number!");
795 ocean_assert(source && denominators && target && zeroValue);
796 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
800 target += firstRow * width * tChannels;
801 denominators += firstRow * width;
802 source += firstRow * width * tChannels;
804 const unsigned int*
const sourceEnd = source + numberRows * width * tChannels;
806 while (source != sourceEnd)
808 ocean_assert(source < sourceEnd);
812 const unsigned int denominator = *denominators;
813 const unsigned int denominator_2 = denominator / 2u;
815 for (
unsigned int n = 0u; n < tChannels; ++n)
817 target[n] = (uint8_t)((source[n] + denominator_2) / denominator);
822 *((PixelType*)target) = *((PixelType*)zeroValue);
832 template <
unsigned int tChannels>
835 static_assert(tChannels >= 1u,
"Invalid channel number!");
837 ocean_assert(sourceWithDenominator && target && zeroValue);
838 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
842 target += firstRow * width * tChannels;
843 sourceWithDenominator += firstRow * width * (tChannels + 1u);
845 const unsigned int*
const sourceEnd = sourceWithDenominator + numberRows * width * (tChannels + 1u);
847 while (sourceWithDenominator != sourceEnd)
849 ocean_assert(sourceWithDenominator < sourceEnd);
851 if (sourceWithDenominator[tChannels])
853 const unsigned int denominator = sourceWithDenominator[tChannels];
854 const unsigned int denominator_2 = denominator / 2u;
856 for (
unsigned int n = 0u; n < tChannels; ++n)
858 target[n] = (uint8_t)((sourceWithDenominator[n] + denominator_2) / denominator);
863 *((PixelType*)target) = *((PixelType*)zeroValue);
867 sourceWithDenominator += (tChannels + 1u);
static bool convert(const Frame &source, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, Frame &target, const bool forceCopy=true, Worker *worker=nullptr, const Options &options=Options())
Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same d...
@ CP_AVOID_COPY_IF_POSSIBLE
Tries to avoid copying the frame data whenever possible.
Definition: FrameConverter.h:96
This class implements functions allowing to determine e.g., the mean pixel value of a frame of a mean...
Definition: FrameMean.h:30
static void normalizeFrame(const TSource *const source, TTarget *const target, const TSource denominator, unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Normalizes the pixels values of a given (accumulated frame) by a given denominator.
Definition: FrameMean.h:508
static void addToFrameSubset(const TSource *const source, TTarget *const target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Adds the subset of individual pixel values of a given source frame to a target frame.
Definition: FrameMean.h:625
static void normalizeFrameSubset(const TSource *const source, TTarget *const target, const TSource denominator, unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Normalizes a subset of the pixels values of a given (accumulated frame) by a given denominator.
Definition: FrameMean.h:758
static void normalizeFrameIndividually8BitPerChannel(const unsigned int *source, const unsigned int *denominators, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t *zeroValue=nullptr, Worker *worker=nullptr)
Normalizes the pixels values of a given (accumulated frame) by individual denominator values.
Definition: FrameMean.h:526
static Frame meanFrame8BitPerChannel(FrameProviderInterface &frameProviderInterface, const FrameType::PixelFormat &targetPixelFormat, const unsigned int firstFrameIndex, const unsigned int lastFrameIndex, Worker *worker=nullptr, bool *abort=nullptr)
Determines the mean frame for a given set of frames.
Definition: FrameMean.h:371
static void normalizeFrameIndividually8BitPerChannelSubset(const unsigned int *source, const unsigned int *denominators, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t *zeroValue, const unsigned int firstRow, const unsigned int numberRows)
Normalizes a subset of the pixels values of a given (accumulated frame) by individual denominator val...
Definition: FrameMean.h:791
static void sumFrameSubset(const T *frame, const unsigned int width, TSum *sumValues, Lock *lock, const unsigned int framePaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Sums the pixel values in a subset of a given frame.
Definition: FrameMean.h:566
static Frame meanFrame(FrameProviderInterface &frameProviderInterface, const FrameType::PixelFormat &targetPixelFormat, const unsigned int firstFrameIndex, const unsigned int lastFrameIndex, Worker *worker=nullptr, bool *abort=nullptr)
Determines the mean frame for a given set of frames.
static void addToFrameIndividuallyBlock8BitPerChannelSubset(const uint8_t *source, const uint8_t *mask, unsigned int *target, unsigned int *denominators, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int maskPaddingElements, const unsigned int targetPaddingElements, const unsigned int denominatorsPaddingElements, const uint8_t nonMaskValue, const unsigned int firstRow, const unsigned int numberRows)
Adds the subset of individual pixel values of a given source frame to a target frame (with denominato...
Definition: FrameMean.h:649
static void addToFrameIndividually8BitPerChannel(const uint8_t *source, const uint8_t *mask, unsigned int *target, unsigned int *denominators, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int maskPaddingElements, const unsigned int targetPaddingElements, const unsigned int denominatorsPaddingElements, const uint8_t nonMaskValue, Worker *worker=nullptr)
Adds the individual pixel values of a given source frame to a target frame if the corresponding mask ...
Definition: FrameMean.h:454
static void addToFrameIndividuallyZipped8BitPerChannelSubset(const uint8_t *source, unsigned int *targetWithDenominator, const unsigned int width, const unsigned int height, const unsigned int firstRow, const unsigned int numberRows)
Adds the subset of individual pixel values of a given source frame to a target frame (with zipped den...
Definition: FrameMean.h:699
static bool addToFrameIndividually(const Frame &source, const Frame &mask, Frame &target, Frame &denominators, const uint8_t nonMaskValue, Worker *worker=nullptr)
Adds the individual pixel values of a given source frame to a target frame if the corresponding mask ...
static void meanValue(const T *frame, const unsigned int width, const unsigned int height, TMean *meanValues, const unsigned int framePaddingElements, Worker *worker=nullptr)
Determines the mean pixel value for a given frame.
Definition: FrameMean.h:327
static void addToFrame(const TSource *const source, TTarget *const target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Adds the individual pixel values of a given source frame to a target frame.
Definition: FrameMean.h:435
This class defines an abstract interface allowing to request frames from any kind of frame provider.
Definition: FrameProviderInterface.h:38
virtual bool isInitialized()=0
Returns whether the internal information of this interface has been initialized already and whether r...
virtual unsigned int synchronFrameNumberRequest(const double timeout=10.0, bool *abort=nullptr)=0
Invokes a synchronous frame number request.
virtual FrameType synchronFrameTypeRequest(const double timeout=10.0, bool *abort=nullptr)=0
Invokes a synchronous frame type request.
virtual void frameCacheRequest(const unsigned int index, const int range)
Invokes a suggestion to pre-load or to cache some frames that might be requested soon.
virtual FrameRef synchronFrameRequest(const unsigned int index, const double timeout=10.0, bool *abort=nullptr)=0
Invokes a synchronous frame request.
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
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
const T * constdata(const unsigned int planeIndex=0u) const
Returns a pointer to the read-only pixel data of a specific plane.
Definition: Frame.h:4168
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition: Frame.h:4159
bool setValue(const uint8_t value, const unsigned int planeIndex=0u, const bool skipPaddingData=true)
Sets the memory of the frame to a specified byte value (the memory of one plane).
unsigned int paddingElements(const unsigned int planeIndex=0u) const
Returns the optional number of padding elements at the end of each row for a specific plane.
Definition: Frame.h:4042
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition: Frame.h:30
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition: Frame.h:183
unsigned int width() const
Returns the width of the frame format in pixel.
Definition: Frame.h:3143
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition: Frame.h:3188
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition: Frame.h:3153
@ ORIGIN_UPPER_LEFT
The first pixel lies in the upper left corner, the last pixel in the lower right corner.
Definition: Frame.h:1050
unsigned int height() const
Returns the height of the frame in pixel.
Definition: Frame.h:3148
bool isValid() const
Returns whether this frame type is valid.
Definition: Frame.h:3213
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition: Frame.h:3173
This class implements a recursive lock object.
Definition: Lock.h:31
T TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition: DataType.h:261
This class provides basic numeric functionalities.
Definition: Numeric.h:57
This template class implements a object reference with an internal reference counter.
Definition: base/ObjectRef.h:58
bool isNull() const
Returns whether this object reference holds no internal object.
Definition: base/ObjectRef.h:390
This class implements an optional recursive scoped lock object locking the lock object only if it's d...
Definition: Lock.h:325
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.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15