Ocean
Ocean::CV::PixelBoundingBoxT< T > Class Template Reference

This class implements a 2D bounding box with pixel precision. More...

Inheritance diagram for Ocean::CV::PixelBoundingBoxT< T >:

Public Member Functions

 PixelBoundingBoxT ()
 Creates a empty bounding box. More...
 
 PixelBoundingBoxT (const PixelBoundingBoxT< T > &boundingBox)
 Copy constructor. More...
 
 PixelBoundingBoxT (const PixelPositionT< T > &point)
 Creates a bounding box covering one point only. More...
 
 PixelBoundingBoxT (const std::vector< PixelPositionT< T >> &points)
 Creates a bounding box covering several points. More...
 
 PixelBoundingBoxT (const T left, const T top, const T right, const T bottom)
 Creates a bounding box with specified dimension. More...
 
 PixelBoundingBoxT (const PixelPositionT< T > &topLeft, const unsigned int width, const unsigned int height)
 Creates a bounding box by a given top left position and a width and height of the bounding box. More...
 
 PixelBoundingBoxT (const PixelPositionT< T > &point0, const PixelPositionT< T > &point1)
 Creates a bounding box covering two points. More...
 
left () const
 Returns the left (including) pixel position of this bounding box. More...
 
top () const
 Returns the top (including) pixel position of this bounding box. More...
 
right () const
 Returns the right (including) pixel position of this bounding box. More...
 
rightEnd () const
 Returns the right (excluding) pixel position of this bounding box. More...
 
bottom () const
 Returns the bottom (including) position of this bounding box. More...
 
bottomEnd () const
 Returns the bottom (excluding) pixel position of this bounding box. More...
 
PixelPositionT< T > topLeft () const
 Returns the top left corner of this bounding box. More...
 
PixelPositionT< T > topRight () const
 Returns the top right corner of this bounding box. More...
 
PixelPositionT< T > bottomLeft () const
 Returns the bottom left corner of this bounding box. More...
 
PixelPositionT< T > bottomRight () const
 Returns the bottom right corner of this bounding box. More...
 
unsigned int width () const
 Returns the width (the number of horizontal including pixels) of this bounding box. More...
 
unsigned int height () const
 Returns the height (the number of vertical including pixels) of this bounding box. More...
 
unsigned int size () const
 Returns the area (the number of including pixels) this bounding box covers. More...
 
bool isInside (const PixelPositionT< T > &point) const
 Returns whether a given point lies inside this bounding box. More...
 
bool isInside (const PixelBoundingBoxT< T > &boundingBox) const
 Returns whether a given bounding box lies entirely inside this bounding box. More...
 
bool hasIntersection (const PixelBoundingBoxT< T > &boundingBox) const
 Returns whether a given bounding box has an intersection with this bounding box. More...
 
bool isTouching (const PixelBoundingBoxT< T > &boundingBox, const bool useNeighborhood8) const
 Returns whether a given bounding box is touching this bounding box. More...
 
PixelBoundingBoxT< T > extended (const unsigned int pixels, const T minLeft, const T minTop, const T maxRight, const T maxBottom) const
 Returns a new bounding box by extending this bounding box with a given number of pixel in each direction. More...
 
bool isValid () const
 Returns whether this bounding box covers a valid pixel area. More...
 
PixelBoundingBoxT< T > & operator+= (const PixelPositionT< T > &point)
 Adds a new point to the bounding box. More...
 
PixelBoundingBoxT< T > & operator= (const PixelBoundingBoxT< T > &other)=default
 Assignment operator override to match copy constructor. More...
 
bool operator== (const PixelBoundingBoxT< T > &box) const
 Returns whether two bounding boxes are equal. More...
 
bool operator!= (const PixelBoundingBoxT< T > &box) const
 Returns whether two bounding boxes are not equal. More...
 
PixelBoundingBoxT< T > operator* (const T factor) const
 Multiplies this bounding box by a specified scalar (multiplies left, top, right, and bottom location by the scalar). More...
 
PixelBoundingBoxT< T > & operator*= (const T factor)
 Multiplies this bounding box by a specified scalar (multiplies left, top, right, and bottom location by the scalar). More...
 
PixelBoundingBoxT< T > operator/ (const T factor) const
 Divides this bounding box by a specified scalar (divides left, top, right, and bottom location by the scalar). More...
 
PixelBoundingBoxT< T > & operator/= (const T factor)
 Divides this bounding box by a specified scalar (divides left, top, right, and bottom location by the scalar). More...
 
PixelBoundingBoxT< T > operator|| (const PixelBoundingBoxT< T > &box) const
 Returns the union of two bounding boxes. More...
 
PixelBoundingBoxT< T > operator&& (const PixelBoundingBoxT< T > &box) const
 Returns the intersection of two bounding boxes. More...
 
size_t operator() (const PixelBoundingBoxT< T > &boundingBox) const
 Hash function. More...
 
 operator bool () const
 Returns whether this bounding box covers a valid pixel area. More...
 

Private Attributes

left_
 Left (including) pixel position of this bounding box. More...
 
top_
 Top (including) pixel position of this bounding box. More...
 
right_
 Right (including) pixel position of this bounding box. More...
 
bottom_
 Bottom (including) pixel position of this bounding box. More...
 

Detailed Description

template<typename T>
class Ocean::CV::PixelBoundingBoxT< T >

This class implements a 2D bounding box with pixel precision.

Constructor & Destructor Documentation

◆ PixelBoundingBoxT() [1/7]

template<typename T >
Ocean::CV::PixelBoundingBoxT< T >::PixelBoundingBoxT
inline

Creates a empty bounding box.

◆ PixelBoundingBoxT() [2/7]

template<typename T >
Ocean::CV::PixelBoundingBoxT< T >::PixelBoundingBoxT ( const PixelBoundingBoxT< T > &  boundingBox)
inline

Copy constructor.

Parameters
boundingBoxThe bounding box to copy

◆ PixelBoundingBoxT() [3/7]

template<typename T >
Ocean::CV::PixelBoundingBoxT< T >::PixelBoundingBoxT ( const PixelPositionT< T > &  point)
inlineexplicit

Creates a bounding box covering one point only.

Parameters
pointThe point the box will cover

◆ PixelBoundingBoxT() [4/7]

template<typename T >
Ocean::CV::PixelBoundingBoxT< T >::PixelBoundingBoxT ( const std::vector< PixelPositionT< T >> &  points)
inlineexplicit

Creates a bounding box covering several points.

Parameters
pointsThe points the box will cover

◆ PixelBoundingBoxT() [5/7]

template<typename T >
Ocean::CV::PixelBoundingBoxT< T >::PixelBoundingBoxT ( const T  left,
const T  top,
const T  right,
const T  bottom 
)
inline

Creates a bounding box with specified dimension.

Parameters
leftLeft (including) pixel position
topTop (including) pixel position
rightRight (including) pixel position, with range [left, infinity) to create a valid bounding box
bottomBottom (including) pixel position, with range [top, infinity) to create a valid bounding box

◆ PixelBoundingBoxT() [6/7]

template<typename T >
Ocean::CV::PixelBoundingBoxT< T >::PixelBoundingBoxT ( const PixelPositionT< T > &  topLeft,
const unsigned int  width,
const unsigned int  height 
)
inline

Creates a bounding box by a given top left position and a width and height of the bounding box.

Parameters
topLeftTop left position of the box
widthThe width of the bounding box in pixel with range [1, infinity)
heightThe height of the bounding box in pixel, with range [1, infinity)

◆ PixelBoundingBoxT() [7/7]

template<typename T >
Ocean::CV::PixelBoundingBoxT< T >::PixelBoundingBoxT ( const PixelPositionT< T > &  point0,
const PixelPositionT< T > &  point1 
)
inline

Creates a bounding box covering two points.

Parameters
point0The first point that will be converted by the bounding box
point1The second point that will be converted by the bounding box

Member Function Documentation

◆ bottom()

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::bottom
inline

Returns the bottom (including) position of this bounding box.

Returns
Bottom position

◆ bottomEnd()

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::bottomEnd
inline

Returns the bottom (excluding) pixel position of this bounding box.

Returns
First pixel below the bounding box

◆ bottomLeft()

template<typename T >
PixelPositionT< T > Ocean::CV::PixelBoundingBoxT< T >::bottomLeft
inline

Returns the bottom left corner of this bounding box.

Returns
bottom left corner

◆ bottomRight()

template<typename T >
PixelPositionT< T > Ocean::CV::PixelBoundingBoxT< T >::bottomRight
inline

Returns the bottom right corner of this bounding box.

Returns
Bottom right corner

◆ extended()

template<typename T >
PixelBoundingBoxT< T > Ocean::CV::PixelBoundingBoxT< T >::extended ( const unsigned int  pixels,
const T  minLeft,
const T  minTop,
const T  maxRight,
const T  maxBottom 
) const
inline

Returns a new bounding box by extending this bounding box with a given number of pixel in each direction.

Parameters
pixelsNumber of pixels to be added to each bounding box boundary
minLeftMinimal (including) left boundary, with minLeft <= left()
minTopMinimal (including) top boundary, with minTop <= top()
maxRightMinimal (including) right boundary, with maxRight >= right()
maxBottomMinimal (including) bottom boundary, with maxBottom >= bottom()
Returns
Extended bounding box

◆ hasIntersection()

template<typename T >
bool Ocean::CV::PixelBoundingBoxT< T >::hasIntersection ( const PixelBoundingBoxT< T > &  boundingBox) const
inline

Returns whether a given bounding box has an intersection with this bounding box.

Parameters
boundingBoxThe bounding box to be checked, must be valid
Returns
True, if so

◆ height()

template<typename T >
unsigned int Ocean::CV::PixelBoundingBoxT< T >::height
inline

Returns the height (the number of vertical including pixels) of this bounding box.

Returns
Bounding box height

◆ isInside() [1/2]

template<typename T >
bool Ocean::CV::PixelBoundingBoxT< T >::isInside ( const PixelBoundingBoxT< T > &  boundingBox) const
inline

Returns whether a given bounding box lies entirely inside this bounding box.

Parameters
boundingBoxThe bounding box to be checked, must be valid
Returns
True, if so

◆ isInside() [2/2]

template<typename T >
bool Ocean::CV::PixelBoundingBoxT< T >::isInside ( const PixelPositionT< T > &  point) const
inline

Returns whether a given point lies inside this bounding box.

Parameters
pointThe point to be checked, must be valid
Returns
True, if so

◆ isTouching()

template<typename T >
bool Ocean::CV::PixelBoundingBoxT< T >::isTouching ( const PixelBoundingBoxT< T > &  boundingBox,
const bool  useNeighborhood8 
) const
inline

Returns whether a given bounding box is touching this bounding box.

Two bounding boxes are touching if both boxes are intersecting or if both boxes have a touching edge.
When two bounding boxes are touching at the corners, the 'useNeighborhood4' property defines whether both boxes count as touching or not.

Parameters
boundingBoxThe bounding box to be checked, must be valid
useNeighborhood8True, to use a 8-neighborhood during the check; False, to use an 4-neighborhood during the check
Returns
True, if so

◆ isValid()

template<typename T >
bool Ocean::CV::PixelBoundingBoxT< T >::isValid
inline

Returns whether this bounding box covers a valid pixel area.

Returns
True, if so

◆ left()

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::left
inline

Returns the left (including) pixel position of this bounding box.

Returns
Left position

◆ operator bool()

template<typename T >
Ocean::CV::PixelBoundingBoxT< T >::operator bool
inlineexplicit

Returns whether this bounding box covers a valid pixel area.

Returns
True, if so

◆ operator!=()

template<typename T >
bool Ocean::CV::PixelBoundingBoxT< T >::operator!= ( const PixelBoundingBoxT< T > &  box) const
inline

Returns whether two bounding boxes are not equal.

Parameters
boxSecond bounding box
Returns
True, if so

◆ operator&&()

template<typename T >
PixelBoundingBoxT< T > Ocean::CV::PixelBoundingBoxT< T >::operator&& ( const PixelBoundingBoxT< T > &  box) const
inline

Returns the intersection of two bounding boxes.

Beware: The intersection between a valid and an invalid bounding box is an invalid bounding box.

Parameters
boxSecond bounding box
Returns
New intersection bounding box

◆ operator()()

template<typename T >
size_t Ocean::CV::PixelBoundingBoxT< T >::operator() ( const PixelBoundingBoxT< T > &  boundingBox) const
inline

Hash function.

Parameters
boundingBoxThe bounding box for which the hash value will be determined
Returns
The resulting hash value

◆ operator*()

template<typename T >
PixelBoundingBoxT< T > Ocean::CV::PixelBoundingBoxT< T >::operator* ( const T  factor) const
inline

Multiplies this bounding box by a specified scalar (multiplies left, top, right, and bottom location by the scalar).

Parameters
factorThe multiplication factor, with range (-infinity, infinity)
Returns
The new (bigger/multiplied) bounding box

◆ operator*=()

template<typename T >
PixelBoundingBoxT< T > & Ocean::CV::PixelBoundingBoxT< T >::operator*= ( const T  factor)
inline

Multiplies this bounding box by a specified scalar (multiplies left, top, right, and bottom location by the scalar).

Parameters
factorThe multiplication factor, with range (-infinity, infinity)
Returns
Reference to this modified bounding box

◆ operator+=()

template<typename T >
PixelBoundingBoxT< T > & Ocean::CV::PixelBoundingBoxT< T >::operator+= ( const PixelPositionT< T > &  point)
inline

Adds a new point to the bounding box.

If the point lies inside the bounding box the box is unchanged, otherwise the box will be extended

Parameters
pointThe point extending the box
Returns
Reference to this box

◆ operator/()

template<typename T >
PixelBoundingBoxT< T > Ocean::CV::PixelBoundingBoxT< T >::operator/ ( const T  factor) const
inline

Divides this bounding box by a specified scalar (divides left, top, right, and bottom location by the scalar).

Parameters
factorThe division factor, with range (-infinity, infinity) \ {0}
Returns
The new (smaller/divided) bounding box

◆ operator/=()

template<typename T >
PixelBoundingBoxT< T > & Ocean::CV::PixelBoundingBoxT< T >::operator/= ( const T  factor)
inline

Divides this bounding box by a specified scalar (divides left, top, right, and bottom location by the scalar).

Parameters
factorThe division factor, with range (-infinity, infinity) \ {0}
Returns
Reference to this modified bounding box

◆ operator=()

template<typename T >
PixelBoundingBoxT<T>& Ocean::CV::PixelBoundingBoxT< T >::operator= ( const PixelBoundingBoxT< T > &  other)
inlinedefault

Assignment operator override to match copy constructor.

◆ operator==()

template<typename T >
bool Ocean::CV::PixelBoundingBoxT< T >::operator== ( const PixelBoundingBoxT< T > &  box) const
inline

Returns whether two bounding boxes are equal.

Parameters
boxSecond bounding box
Returns
True, if so

◆ operator||()

template<typename T >
PixelBoundingBoxT< T > Ocean::CV::PixelBoundingBoxT< T >::operator|| ( const PixelBoundingBoxT< T > &  box) const
inline

Returns the union of two bounding boxes.

Parameters
boxSecond bounding box
Returns
New union bounding box

◆ right()

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::right
inline

Returns the right (including) pixel position of this bounding box.

Returns
Right position

◆ rightEnd()

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::rightEnd
inline

Returns the right (excluding) pixel position of this bounding box.

Returns
First pixel to the right of the bounding box

◆ size()

template<typename T >
unsigned int Ocean::CV::PixelBoundingBoxT< T >::size
inline

Returns the area (the number of including pixels) this bounding box covers.

If this bounding box is invalid, than zero is returned.

Returns
Number of pixels or zero.

◆ top()

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::top
inline

Returns the top (including) pixel position of this bounding box.

Returns
Top position

◆ topLeft()

template<typename T >
PixelPositionT< T > Ocean::CV::PixelBoundingBoxT< T >::topLeft
inline

Returns the top left corner of this bounding box.

Returns
Top left corner

◆ topRight()

template<typename T >
PixelPositionT< T > Ocean::CV::PixelBoundingBoxT< T >::topRight
inline

Returns the top right corner of this bounding box.

Returns
Top right corner

◆ width()

template<typename T >
unsigned int Ocean::CV::PixelBoundingBoxT< T >::width
inline

Returns the width (the number of horizontal including pixels) of this bounding box.

Returns
Bounding box width

Field Documentation

◆ bottom_

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::bottom_
private

Bottom (including) pixel position of this bounding box.

◆ left_

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::left_
private

Left (including) pixel position of this bounding box.

◆ right_

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::right_
private

Right (including) pixel position of this bounding box.

◆ top_

template<typename T >
T Ocean::CV::PixelBoundingBoxT< T >::top_
private

Top (including) pixel position of this bounding box.


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