文章目錄
- 1.頭檔案關于size的原始碼
- 2.我看出來的一些玩意
- 3.為什么要水這篇文章(zise的width和height定義的時候一定要>=0)
1.頭檔案關于size的原始碼
Size_
/** @brief Template class for specifying the size of an image or rectangle.
The class includes two members called width and height. The structure can be converted to and from
the old OpenCV structures CvSize and CvSize2D32f . The same set of arithmetic and comparison
operations as for Point_ is available.
OpenCV defines the following Size_\<\> aliases:
@code
typedef Size_<int> Size2i;
typedef Size2i Size;
typedef Size_<float> Size2f;
@endcode
*/
template<typename _Tp> class Size_
{
public:
typedef _Tp value_type;
//! default constructor
Size_();
Size_(_Tp _width, _Tp _height);
Size_(const Size_& sz);
Size_(Size_&& sz) CV_NOEXCEPT;
Size_(const Point_<_Tp>& pt);
Size_& operator = (const Size_& sz);
Size_& operator = (Size_&& sz) CV_NOEXCEPT;
//! the area (width*height)
_Tp area() const;
//! aspect ratio (width/height)
double aspectRatio() const;
//! true if empty
bool empty() const;
//! conversion of another data type.
template<typename _Tp2> operator Size_<_Tp2>() const;
_Tp width; //!< the width
_Tp height; //!< the height
};
typedef Size_<int> Size2i;
typedef Size_<int64> Size2l;
typedef Size_<float> Size2f;
typedef Size_<double> Size2d;
typedef Size2i Size;
2.我看出來的一些玩意
通過原始碼可以看見size的幾種定義方式
typedef Size_<int> Size2i;
typedef Size_<int64> Size2l;
typedef Size_<float> Size2f;
typedef Size_<double> Size2d;
typedef Size2i Size;
分別代表width和height的不同的資料型別
_Tp width; //!< the width
_Tp height; //!< the height
然后我們一般定義Size時默認為<int>型別,也就是Size2i
然后是有一些常用的函式
//! the area (width*height)
_Tp area() const;
//! aspect ratio (width/height)
double aspectRatio() const;
//! true if empty
bool empty() const;
也就是計算面積,長寬比和是否為空
3.為什么要水這篇文章(zise的width和height定義的時候一定要>=0)
zise的width和height定義的時候一定要>=0
特別是在自己玩動態調參的時候!!
一開始用動態調參的時候一直報錯,然后網上查原因,可惜全網就我一個人這么憨,然后懷疑是型別不對,之前mat型別沒用對也是報的記憶體錯誤,反正搞了一個小時誤打誤撞找到了原因,
好氣,等哪天氣消了再把這篇文章給刪了哎,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/388028.html
標籤:其他
