CvRect、RECT和Rect

CvRect定义:在...build\include\opencv2\core\types_c.h下

[cpp]  view plain  copy
  1. typedef struct CvRect  
  2. {  
  3.     int x;  
  4.     int y;  
  5.     int width;  
  6.     int height;  
  7. }  
  8. CvRect;  
RECT定义:在WinDef.h下
[cpp]  view plain  copy
  1. typedef struct tagRECT  
  2. {  
  3.     LONG    left;  
  4.     LONG    top;  
  5.     LONG    right;  
  6.     LONG    bottom;  
  7. } RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;  

Rect定义:在core.hpp下

和CvRect相同也是x,y,width,height

[cpp]  view plain  copy
  1. "font-family: Arial, Helvetica, sans-serif;">typedef Rect_<int> Rect  
[cpp]  view plain  copy
  1. template<typename _Tp> class Rect_  
  2. {  
  3. public:  
  4.     typedef _Tp value_type;  
  5.   
  6.     //! various constructors  
  7.     Rect_();  
  8.     Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height);    //和CvRect相同也是下,x,y,width,height  
  9.     Rect_(const Rect_& r);  
  10.     Rect_(const CvRect& r);  
  11.     Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz);  
  12.     Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2);  
  13.   
  14.     Rect_& operator = ( const Rect_& r );  
  15.     //! the top-left corner  
  16.     Point_<_Tp> tl() const;  
  17.     //! the bottom-right corner  
  18.     Point_<_Tp> br() const;  
  19.   
  20.     //! size (width, height) of the rectangle  
  21.     Size_<_Tp> size() const;  
  22.     //! area (width*height) of the rectangle  
  23.     _Tp area() const;  
  24.   
  25.     //! conversion to another data type  
  26.     template<typename _Tp2> operator Rect_<_Tp2>() const;  
  27.     //! conversion to the old-style CvRect  
  28.     operator CvRect() const;  
  29.   
  30.     //! checks whether the rectangle contains the point  
  31.     bool contains(const Point_<_Tp>& pt) const;  
  32.   
  33.     _Tp x, y, width, height; //< the top-left corner, as well as width and height of the rectangle  
  34. };  

你可能感兴趣的:(OpenCV学习笔记)