OpenCV for Unity  2.6.0
Enox Software / Please refer to OpenCV official document ( ) for the details of the argument of the method.
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
OpenCVForUnity.CoreModule.Rect Class Reference
Inheritance diagram for OpenCVForUnity.CoreModule.Rect:

Public Member Functions

 Rect (int x, int y, int width, int height)
 Rect ()
 Rect (Point p1, Point p2)
 Rect (Point p, Size s)
 Rect (double[] vals)
void set (double[] vals)
Rect clone ()
Point tl ()
Point br ()
Size size ()
double area ()
bool empty ()
bool contains (Point p)
override int GetHashCode ()
override bool Equals (Object obj)
override string ToString ()
bool Equals (Rect a)
bool contains (int x, int y)
bool contains (Rect rect)
void inflate (int width, int height)
void inflate (Size size)
Rect intersect (Rect rect)
bool intersectsWith (Rect rect)
Rect union (Rect rect)

Static Public Member Functions

static Rect operator+ (Rect a, Point b)
static Rect operator+ (Rect a, Size b)
static Rect operator- (Rect a, Point b)
static Rect operator- (Rect a, Size b)
static Rect operator& (Rect a, Rect b)
static Rect operator| (Rect a, Rect b)
static bool operator== (Rect a, Rect b)
static bool operator!= (Rect a, Rect b)
static Rect inflate (Rect rect, int x, int y)
static Rect intersect (Rect a, Rect b)
static Rect union (Rect a, Rect b)

Public Attributes

int x

Detailed Description

template<typename _Tp> class CV_EXPORTS Rect_

// C++ code:


typedef _Tp value_type;

//! various constructors


Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height);

Rect_(const Rect_& r);

Rect_(const CvRect& r);

Rect_(const Point_<Tp>& org, const Size<_Tp>& sz);

Rect_(const Point_<Tp>& pt1, const Point<_Tp>& pt2);

Rect_& operator = (const Rect_& r);

//! the top-left corner

Point_<_Tp> tl() const;

//! the bottom-right corner

Point_<_Tp> br() const;

//! size (width, height) of the rectangle

Size_<_Tp> size() const;

//! area (width*height) of the rectangle

_Tp area() const;

//! conversion to another data type

template<typename _Tp2> operator Rect_<_Tp2>() const;

//! conversion to the old-style CvRect

operator CvRect() const;

//! checks whether the rectangle contains the point

bool contains(const Point_<_Tp>& pt) const;

_Tp x, y, width, height; //< the top-left corner, as well as width and height of the rectangle


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 <= pt.x &lt x+width,&ltBR&gty <= pt.y &lt y+height

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

// C++ code:

for(int y = roi.y; y < roi.y + rect.height; y++)

for(int x = roi.x; x < roi.x + rect.width; x++)


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 (rect1subseteq rect2):

// C++ code:

template<typename _Tp> inline bool

operator <= (const Rect_<Tp>& r1, const Rect<_Tp>& r2)

return (r1 & r2) == r1;

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

typedef Rect_<int> Rect;

See also

Constructor & Destructor Documentation

◆ Rect() [1/5]

OpenCVForUnity.CoreModule.Rect.Rect ( int  x,
int  y,
int  width,
int  height 

◆ Rect() [2/5]

OpenCVForUnity.CoreModule.Rect.Rect ( )

◆ Rect() [3/5]

OpenCVForUnity.CoreModule.Rect.Rect ( Point  p1,
Point  p2 

◆ Rect() [4/5]

OpenCVForUnity.CoreModule.Rect.Rect ( Point  p,
Size  s 

◆ Rect() [5/5]

OpenCVForUnity.CoreModule.Rect.Rect ( double []  vals)

Member Function Documentation

◆ area()

double OpenCVForUnity.CoreModule.Rect.area ( )

◆ br()

Point ( )

◆ clone()

Rect OpenCVForUnity.CoreModule.Rect.clone ( )

◆ contains() [1/3]

bool OpenCVForUnity.CoreModule.Rect.contains ( int  x,
int  y 

◆ contains() [2/3]

bool OpenCVForUnity.CoreModule.Rect.contains ( Rect  rect)

◆ contains() [3/3]

bool OpenCVForUnity.CoreModule.Rect.contains ( Point  p)

◆ empty()

bool OpenCVForUnity.CoreModule.Rect.empty ( )

◆ Equals() [1/2]

bool OpenCVForUnity.CoreModule.Rect.Equals ( Rect  a)

◆ Equals() [2/2]

override bool OpenCVForUnity.CoreModule.Rect.Equals ( Object  obj)

◆ GetHashCode()

override int OpenCVForUnity.CoreModule.Rect.GetHashCode ( )

◆ inflate() [1/3]

void OpenCVForUnity.CoreModule.Rect.inflate ( int  width,
int  height 

◆ inflate() [2/3]

void OpenCVForUnity.CoreModule.Rect.inflate ( Size  size)

◆ inflate() [3/3]

static Rect OpenCVForUnity.CoreModule.Rect.inflate ( Rect  rect,
int  x,
int  y 

◆ intersect() [1/2]

static Rect OpenCVForUnity.CoreModule.Rect.intersect ( Rect  a,
Rect  b 

◆ intersect() [2/2]

Rect OpenCVForUnity.CoreModule.Rect.intersect ( Rect  rect)

◆ intersectsWith()

bool OpenCVForUnity.CoreModule.Rect.intersectsWith ( Rect  rect)

◆ operator!=()

static bool OpenCVForUnity.CoreModule.Rect.operator!= ( Rect  a,
Rect  b 

◆ operator&()

static Rect OpenCVForUnity.CoreModule.Rect.operator & ( Rect  a,
Rect  b 

◆ operator+() [1/2]

static Rect OpenCVForUnity.CoreModule.Rect.operator+ ( Rect  a,
Point  b 

◆ operator+() [2/2]

static Rect OpenCVForUnity.CoreModule.Rect.operator+ ( Rect  a,
Size  b 

◆ operator-() [1/2]

static Rect OpenCVForUnity.CoreModule.Rect.operator- ( Rect  a,
Point  b 

◆ operator-() [2/2]

static Rect OpenCVForUnity.CoreModule.Rect.operator- ( Rect  a,
Size  b 

◆ operator==()

static bool OpenCVForUnity.CoreModule.Rect.operator== ( Rect  a,
Rect  b 

◆ operator|()

static Rect OpenCVForUnity.CoreModule.Rect.operator| ( Rect  a,
Rect  b 

◆ set()

void OpenCVForUnity.CoreModule.Rect.set ( double []  vals)

◆ size()

Size OpenCVForUnity.CoreModule.Rect.size ( )

◆ tl()

Point ( )

◆ ToString()

override string OpenCVForUnity.CoreModule.Rect.ToString ( )

◆ union() [1/2]

Rect OpenCVForUnity.CoreModule.Rect.union ( Rect  rect)

◆ union() [2/2]

static Rect OpenCVForUnity.CoreModule.Rect.union ( Rect  a,
Rect  b 

Member Data Documentation

◆ x

int OpenCVForUnity.CoreModule.Rect.x

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