gpt4 book ai didi

c++ - OpenCV rect.width 和 rect.size().width 区别?

转载 作者:行者123 更新时间:2023-11-28 01:26:22 24 4
gpt4 key购买 nike

很抱歉问了一个菜鸟问题,但是有人能告诉我这两者之间的区别吗

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 and height是公共(public)成员变量:

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);
}

关于c++ - OpenCV rect.width 和 rect.size().width 区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53605538/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com