[英]OpenCV rect.width and rect.size().width difference?
很抱歉提出一個菜鳥問題,但是有人可以告訴我這之間的區別嗎
cv:: Rect rect;
int width = rect.width;
int height = rect.height;
和這個
cv::Rect rect;
int width = rect.size().width;
int height = rect.size().height;
它們是相同的, 沒有區別 。
OpenCV是開源的,因此您可以隨時查看源代碼。
您可以看到width
和height
是公共成員變量:
template<typename _Tp> class Rect_
{
public:
...
_Tp width; //!< width of the rectangle
_Tp height; //!< height of the rectangle
};
和size()
返回一個用其值初始化的cv::Size
:
template<typename _Tp> inline
Size_<_Tp> Rect_<_Tp>::size() const
{
return Size_<_Tp>(width, height);
}
顯示的代碼沒有區別。
但是, width
和height
是Rect
公共屬性,如果更改它們,將更改Rect
。
size()
僅返回Rect
的大小(寬度,高度)。 您不能通過size()
的成員更改Rect
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.