nndeploy C++ API  0.2.0
nndeploy C++ API
Public Types | Public Member Functions | Public Attributes | List of all members
nndeploy::base::Rect< T > Class Template Reference

Template class for 2D rectangles described by the following parameters: More...

#include <type.h>

Public Types

typedef T value_type
 

Public Member Functions

area () const
 area (width_*height_) of the rectangle More...
 
Point< T > br () const
 the bottom-right corner More...
 
bool contains (const Point< T > &pt) const
 checks whether the rectangle contains the point More...
 
bool empty () const
 true if empty More...
 
template<typename Tp2 >
 operator Rect< Tp2 > () const
 conversion to another data type More...
 
Rectoperator= (const Rect &r)=default
 
Rectoperator= (Rect &&r)=default
 
 Rect ()
 default constructor More...
 
 Rect (const Point< T > &org, const Size< T > &sz)
 
 Rect (const Point< T > &pt1, const Point< T > &pt2)
 
 Rect (const Rect &r)=default
 
 Rect (Rect &&r)=default
 
 Rect (T x, T y, T width, T height)
 
Size< T > size () const
 size (width_, height_) of the rectangle More...
 
Point< T > tl () const
 the top-left corner More...
 

Public Attributes

height_
 height_ of the rectangle More...
 
width_
 width_ of the rectangle More...
 
x_
 x_ coordinate of the top-left corner More...
 
y_
 y_ coordinate of the top-left corner More...
 

Detailed Description

template<typename T>
class nndeploy::base::Rect< T >

Template class for 2D rectangles described by the following parameters:

OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the right and bottom boundaries are not. For example, the method Rect::contains returns true if

\[x_ \leq pt.x_ < x_+width_, y_ \leq pt.y_ < y_+height_\]

Virtually every loop over an image ROI in OpenCV (where ROI is specified by Rect<int> ) is implemented as:

for(int y_ = roi.y_; y_ < roi.y_ + roi.height_; y_++)
for(int x_ = roi.x_; x_ < roi.x_ + roi.width_; x_++)
{
// ...
}
T x_
x_ coordinate of the top-left corner
Definition: type.h:368
T y_
y_ coordinate of the top-left corner
Definition: type.h:369

In addition to the class members, the following operations on rectangles are implemented:

This is an example how the partial ordering on rectangles can be established (rect1 $\subseteq$ rect2):

template<typename T> inline bool
operator <= (const Rect<T>& r1, const Rect<T>& r2)
{
return (r1 & r2) == r1;
}

For your convenience, the Rect<> alias is available: Rect

Definition at line 335 of file type.h.

Member Typedef Documentation

◆ value_type

template<typename T >
typedef T nndeploy::base::Rect< T >::value_type

Definition at line 337 of file type.h.

Constructor & Destructor Documentation

◆ Rect() [1/6]

template<typename T >
nndeploy::base::Rect< T >::Rect
inline

default constructor

Definition at line 957 of file type.h.

◆ Rect() [2/6]

template<typename T >
nndeploy::base::Rect< T >::Rect ( x,
y,
width,
height 
)
inline

Definition at line 960 of file type.h.

◆ Rect() [3/6]

template<typename T >
nndeploy::base::Rect< T >::Rect ( const Rect< T > &  r)
default

◆ Rect() [4/6]

template<typename T >
nndeploy::base::Rect< T >::Rect ( Rect< T > &&  r)
default

◆ Rect() [5/6]

template<typename T >
nndeploy::base::Rect< T >::Rect ( const Point< T > &  org,
const Size< T > &  sz 
)
inline

Definition at line 964 of file type.h.

◆ Rect() [6/6]

template<typename T >
nndeploy::base::Rect< T >::Rect ( const Point< T > &  pt1,
const Point< T > &  pt2 
)
inline

Definition at line 968 of file type.h.

Member Function Documentation

◆ area()

template<typename T >
T nndeploy::base::Rect< T >::area
inline

area (width_*height_) of the rectangle

Definition at line 991 of file type.h.

◆ br()

template<typename T >
Point< T > nndeploy::base::Rect< T >::br
inline

the bottom-right corner

Definition at line 981 of file type.h.

◆ contains()

template<typename T >
bool nndeploy::base::Rect< T >::contains ( const Point< T > &  pt) const
inline

checks whether the rectangle contains the point

Definition at line 1009 of file type.h.

◆ empty()

template<typename T >
bool nndeploy::base::Rect< T >::empty
inline

true if empty

Definition at line 997 of file type.h.

◆ operator Rect< Tp2 >()

template<typename T >
template<typename Tp2 >
nndeploy::base::Rect< T >::operator Rect< Tp2 >
inline

conversion to another data type

Definition at line 1003 of file type.h.

◆ operator=() [1/2]

template<typename T >
Rect& nndeploy::base::Rect< T >::operator= ( const Rect< T > &  r)
default

◆ operator=() [2/2]

template<typename T >
Rect& nndeploy::base::Rect< T >::operator= ( Rect< T > &&  r)
default

◆ size()

template<typename T >
Size< T > nndeploy::base::Rect< T >::size
inline

size (width_, height_) of the rectangle

Definition at line 986 of file type.h.

◆ tl()

template<typename T >
Point< T > nndeploy::base::Rect< T >::tl
inline

the top-left corner

Definition at line 976 of file type.h.

Member Data Documentation

◆ height_

template<typename T >
T nndeploy::base::Rect< T >::height_

height_ of the rectangle

Definition at line 371 of file type.h.

◆ width_

template<typename T >
T nndeploy::base::Rect< T >::width_

width_ of the rectangle

Definition at line 370 of file type.h.

◆ x_

template<typename T >
T nndeploy::base::Rect< T >::x_

x_ coordinate of the top-left corner

Definition at line 368 of file type.h.

◆ y_

template<typename T >
T nndeploy::base::Rect< T >::y_

y_ coordinate of the top-left corner

Definition at line 369 of file type.h.


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