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


union  b
union  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)

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)

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

OpenCVForUnity.Rect.Rect ( int  x,
int  y,
int  width,
int  height 
OpenCVForUnity.Rect.Rect ( )
OpenCVForUnity.Rect.Rect ( Point  p1,
Point  p2 
OpenCVForUnity.Rect.Rect ( Point  p,
Size  s 
OpenCVForUnity.Rect.Rect ( double[]  vals)

Member Function Documentation

double OpenCVForUnity.Rect.area ( )
Point ( )
Rect OpenCVForUnity.Rect.clone ( )
bool OpenCVForUnity.Rect.contains ( Point  p)
bool OpenCVForUnity.Rect.contains ( int  x,
int  y 
bool OpenCVForUnity.Rect.contains ( Rect  rect)
bool OpenCVForUnity.Rect.empty ( )
override bool OpenCVForUnity.Rect.Equals ( Object  obj)
bool OpenCVForUnity.Rect.Equals ( Rect  a)
override int OpenCVForUnity.Rect.GetHashCode ( )
void OpenCVForUnity.Rect.inflate ( int  width,
int  height 
void OpenCVForUnity.Rect.inflate ( Size  size)
static Rect OpenCVForUnity.Rect.inflate ( Rect  rect,
int  x,
int  y 
static Rect OpenCVForUnity.Rect.intersect ( Rect  a,
Rect  b 
Rect OpenCVForUnity.Rect.intersect ( Rect  rect)
bool OpenCVForUnity.Rect.intersectsWith ( Rect  rect)
static bool OpenCVForUnity.Rect.operator!= ( Rect  a,
Rect  b 
static Rect OpenCVForUnity.Rect.operator& ( Rect  a,
Rect  b 
static Rect OpenCVForUnity.Rect.operator+ ( Rect  a,
Point  b 
static Rect OpenCVForUnity.Rect.operator+ ( Rect  a,
Size  b 
static Rect OpenCVForUnity.Rect.operator- ( Rect  a,
Point  b 
static Rect OpenCVForUnity.Rect.operator- ( Rect  a,
Size  b 
static bool OpenCVForUnity.Rect.operator== ( Rect  a,
Rect  b 
static Rect OpenCVForUnity.Rect.operator| ( Rect  a,
Rect  b 
void OpenCVForUnity.Rect.set ( double[]  vals)
Size OpenCVForUnity.Rect.size ( )
Point ( )
override string OpenCVForUnity.Rect.ToString ( )

Member Data Documentation

int OpenCVForUnity.Rect.x

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