Opencv Size_是一个模板类,有成员变量_Tp width; _Tp height;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
//////////////////////////////// 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_(const Point_<_Tp>& pt); //转换构造函数 Size_& operator = (const Size_& sz); //! the area (width*height) _Tp area() 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 }; |
Opencv Size_具体定义,重取名:
1 2 3 4 5 |
typedef Size_<int> Size2i; typedef Size_<int64> Size2l; typedef Size_<float> Size2f; typedef Size_<double> Size2d; typedef Size2i Size; |
Opencv Size_运用例子
1 2 3 4 5 |
cv::Size2f s(2.9, 3.4); float area = s.area(); printf("矩形面积:%f", area); Mat Img1(Size(200, 200), CV_8U, Scalar(0)); |
Opencv Size_运用测试结果:
1 |
矩形面积:9.860001 |
《Opencv Size_类数据结构详解》上有1条评论
评论已关闭。