Ocean
Ocean::CV::MaskAnalyzer Class Reference

This class implements basic maks analyzing functions. More...

Static Public Member Functions

static PixelBoundingBox detectBoundingBox (const uint8_t *mask, const unsigned int width, const unsigned int height, const uint8_t nonMaskPixel, const unsigned int maskPaddingElements)
 Detects the smallest axis-aligned bounding box enclosing all isolated mask islands in a binary (but 8-bit) mask frame. More...
 
static PixelBoundingBox detectBoundingBox (const uint8_t *const mask, const unsigned int width, const unsigned int height, const PixelBoundingBox &rough, const unsigned int maxUncertainty, const uint8_t nonMaskPixel=0xFFu, const unsigned int maskPaddingElements=0u)
 Detects the smallest axis-aligned bounding box enclosing all isolated mask islands inside a given mask frame using a rough approximation of the bounding box. More...
 
template<typename T >
static PixelBoundingBox detectOpaqueBoundingBox (const T *frame, const unsigned int width, const unsigned int height, const unsigned int alphaChannelIndex, const unsigned int channels, const T fullTransparentValue, const unsigned int framePaddingElements, Worker *worker=nullptr)
 Detects the smallest bounding box enclosing all opaque pixels in a given frame. More...
 
static PixelBoundingBox detectOpaqueBoundingBox (const Frame &frame, const bool transparentIs0xFF, Worker *worker=nullptr)
 Detects the smallest bounding box of opaque pixels in a given frame. More...
 
static bool hasValue (const uint8_t *mask, const unsigned int width, const unsigned int height, const uint8_t value, const unsigned int maskPaddingElements, const PixelBoundingBox &boundingBox=CV::PixelBoundingBox())
 Returns whether a mask frame has at least one pixel with a specific mask value. More...
 

Static Protected Member Functions

template<typename T >
static void detectOpaqueBoundingBoxSubset (const T *frame, const unsigned int width, const unsigned int height, const unsigned int alphaChannelIndex, const unsigned int channels, const T fullTransparentValue, const unsigned int framePaddingElements, unsigned int *left, unsigned int *top, unsigned int *right, unsigned int *bottom, Lock *lock, const unsigned int firstRow, const unsigned int numberRows)
 Detects the smallest bounding box enclosing all opaque pixels in a subset of a given frame. More...
 

Detailed Description

This class implements basic maks analyzing functions.

More advanced mask analyzing functions are available in CV::Segmentation::MaskAnalyzer.

Member Function Documentation

◆ detectBoundingBox() [1/2]

static PixelBoundingBox Ocean::CV::MaskAnalyzer::detectBoundingBox ( const uint8_t *const  mask,
const unsigned int  width,
const unsigned int  height,
const PixelBoundingBox rough,
const unsigned int  maxUncertainty,
const uint8_t  nonMaskPixel = 0xFFu,
const unsigned int  maskPaddingElements = 0u 
)
static

Detects the smallest axis-aligned bounding box enclosing all isolated mask islands inside a given mask frame using a rough approximation of the bounding box.

Parameters
maskThe 8 bit mask frame in which the bounding box will be determined, must be valid
widthThe width of the mask frame in pixel, with range [1, infinity)
heightThe height of the mask frame in pixel, with range [1, infinity)
roughRough approximation of the final bounding box, must be valid
maxUncertaintyMaximal pixel uncertainty of the rough box guess, with range [1, infinity)
nonMaskPixelThe value of pixel not part of the mask, all other values will be mask pixels, with range [0, infinity)
maskPaddingElementsThe number of padding elements at the end of each mask row, with range [0, infinity)
Returns
Resulting mask bounding box, invalid if no mask could be found

◆ detectBoundingBox() [2/2]

static PixelBoundingBox Ocean::CV::MaskAnalyzer::detectBoundingBox ( const uint8_t *  mask,
const unsigned int  width,
const unsigned int  height,
const uint8_t  nonMaskPixel,
const unsigned int  maskPaddingElements 
)
static

Detects the smallest axis-aligned bounding box enclosing all isolated mask islands in a binary (but 8-bit) mask frame.

Parameters
maskThe 8 bit mask frame in which the enclosing bounding box will be determined, must be valid
widthThe width of the mask frame in pixel, with range [1, infinity)
heightThe height of the mask frame in pixel, with range [1, infinity)
nonMaskPixelThe value of pixels not part of the mask, all other values will be mask pixels, with range [0, infinity)
maskPaddingElementsThe number of padding elements at the end of each mask row, with range [0, infinity)
Returns
Resulting mask bounding box, invalid if no mask could be found
See also
CV::Segmentation::MaskAnalyzer::detectBoundingBoxes().

◆ detectOpaqueBoundingBox() [1/2]

static PixelBoundingBox Ocean::CV::MaskAnalyzer::detectOpaqueBoundingBox ( const Frame frame,
const bool  transparentIs0xFF,
Worker worker = nullptr 
)
static

Detects the smallest bounding box of opaque pixels in a given frame.

Parameters
frameThe frame in the opaque pixels are determined
transparentIs0xFFTrue, if 0xFF is interpreted as a full transparent pixel
workerOptional worker object to distribute the computation
Returns
Resulting smallest bounding box, an invalid bounding box if no opaque pixel has been found

◆ detectOpaqueBoundingBox() [2/2]

template<typename T >
PixelBoundingBox Ocean::CV::MaskAnalyzer::detectOpaqueBoundingBox ( const T *  frame,
const unsigned int  width,
const unsigned int  height,
const unsigned int  alphaChannelIndex,
const unsigned int  channels,
const T  fullTransparentValue,
const unsigned int  framePaddingElements,
Worker worker = nullptr 
)
static

Detects the smallest bounding box enclosing all opaque pixels in a given frame.

Parameters
frameThe frame in which the bounding box enclosing all opaque pixels is determined, must be valid
widthThe width of the frame in pixel, with range [1, infinity)
heightThe height of the frame in pixel, with range [1, infinity)
alphaChannelIndexThe index of the alpha channel, with range [0, channels)
channelsThe number of frame channels, with range [1, infinity)
fullTransparentValueThe alpha pixel value of a full transparent pixel
framePaddingElementsThe number of padding elements at the end of each frame row, in elements, with range [0, infinity)
workerOptional worker object to distribute the computation
Returns
The smallest bounding box enclosing all opaque pixels, an invalid bounding box if the frames does not contain an opaque pixel
Template Parameters
TData type of each pixel channel value

◆ detectOpaqueBoundingBoxSubset()

template<typename T >
void Ocean::CV::MaskAnalyzer::detectOpaqueBoundingBoxSubset ( const T *  frame,
const unsigned int  width,
const unsigned int  height,
const unsigned int  alphaChannelIndex,
const unsigned int  channels,
const T  fullTransparentValue,
const unsigned int  framePaddingElements,
unsigned int *  left,
unsigned int *  top,
unsigned int *  right,
unsigned int *  bottom,
Lock lock,
const unsigned int  firstRow,
const unsigned int  numberRows 
)
staticprotected

Detects the smallest bounding box enclosing all opaque pixels in a subset of a given frame.

Parameters
frameThe frame in which the bounding box enclosing all opaque pixels is determined, must be valid
widthThe width of the frame in pixel, with range [1, infinity)
heightThe height of the frame in pixel, with range [1, infinity)
alphaChannelIndexThe index of the alpha channel, with range [0, channels - 1]
channelsThe number of frame channels, with range [1, infinity)
fullTransparentValueThe alpha pixel value of a full transparent pixel
framePaddingElementsThe number of padding elements at the end of each frame row, in elements, with range [0, infinity)
leftResulting left bounding box position
topResulting top bounding box position
rightResulting right bounding box position
bottomResulting bottom bounding box position
lockOptional lock if this function is executed distributed within several threads
firstRowFirst row to be handled
numberRowsNumber of rows to be handled
Template Parameters
TData type of each pixel channel value

◆ hasValue()

bool Ocean::CV::MaskAnalyzer::hasValue ( const uint8_t *  mask,
const unsigned int  width,
const unsigned int  height,
const uint8_t  value,
const unsigned int  maskPaddingElements,
const PixelBoundingBox boundingBox = CV::PixelBoundingBox() 
)
inlinestatic

Returns whether a mask frame has at least one pixel with a specific mask value.

Parameters
maskThe 8 bit mask frame in which the pixel value is sought, must be valid
widthThe width of the mask frame in pixel, with range [1, infinity)
heightThe height of the mask frame in pixel, with range [1, infinity)
valueThe value to be sought, with range [0, 255]
maskPaddingElementsThe number of padding elements at the end of each mask row, in elements, with range [0, infinity)
boundingBoxOptional bounding box to speedup the computation, must fit into the given frame if defined
Returns
True, if at least one mask pixel has the specified value

The documentation for this class was generated from the following file: