头文件路径:opencv-2.4.9/modules/core/include/opencv2/core/core.hpp
一、Point类
在这些数据类型中,最简单的就是Point点类,Point类是一个包含两个整形数据成员x和y的以及一些简单成员
方法的类类型,和它有关的好几个Point点类的变种如下所示:
typedef Point_<int> Point2i; typedef Point2i Point; typedef Point_<float> Point2f; typedef Point_<double> Point2d; typedef Point3_<int> Point3i; typedef Point3_<float> Point3f; typedef Point3_<double> Point3d;
/*! template 2D point class. The class defines a point in 2D space. Data type of the point coordinates is specified as a template parameter. There are a few shorter aliases available for user convenience. See cv::Point, cv::Point2i, cv::Point2f and cv::Point2d. */ template<typename _Tp> class Point_ { public: typedef _Tp value_type; // various constructors Point_(); Point_(_Tp _x, _Tp _y); Point_(const Point_& pt); Point_(const CvPoint& pt); Point_(const CvPoint2D32f& pt); Point_(const Size_<_Tp>& sz); Point_(const Vec<_Tp, 2>& v); Point_& operator = (const Point_& pt); //! conversion to another data type template<typename _Tp2> operator Point_<_Tp2>() const; //! conversion to the old-style C structures operator CvPoint() const; operator CvPoint2D32f() const; operator Vec<_Tp, 2>() const; //! dot product _Tp dot(const Point_& pt) const; //! dot product computed in double-precision arithmetics double ddot(const Point_& pt) const; //! cross-product double cross(const Point_& pt) const; //! checks whether the point is inside the specified rectangle bool inside(const Rect_<_Tp>& r) const; _Tp x, y; //< the point coordinates };
/*! template 3D point class. The class defines a point in 3D space. Data type of the point coordinates is specified as a template parameter. see cv::Point3i, cv::Point3f and cv::Point3d */ template<typename _Tp> class Point3_ { public: typedef _Tp value_type; // various constructors Point3_(); Point3_(_Tp _x, _Tp _y, _Tp _z); Point3_(const Point3_& pt); explicit Point3_(const Point_<_Tp>& pt); Point3_(const CvPoint3D32f& pt); Point3_(const Vec<_Tp, 3>& v); Point3_& operator = (const Point3_& pt); //! conversion to another data type template<typename _Tp2> operator Point3_<_Tp2>() const; //! conversion to the old-style CvPoint... operator CvPoint3D32f() const; //! conversion to cv::Vec<> operator Vec<_Tp, 3>() const; //! dot product _Tp dot(const Point3_& pt) const; //! dot product computed in double-precision arithmetics double ddot(const Point3_& pt) const; //! cross product of the 2 3D points Point3_ cross(const Point3_& pt) const; _Tp x, y, z; //< the point coordinates };
二、Size类
typedef Size_<int> Size2i; typedef Size_<double> Size2d; typedef Size2i Size; typedef Size_<float> Size2f;
/*! The 2D size class The class represents the size of a 2D rectangle, image size, matrix size etc. Normally, cv::Size ~ cv::Size_<int> is used. */ template<typename _Tp> class Size_ { public: typedef _Tp value_type; //! various constructors Size_(); Size_(_Tp _width, _Tp _height); Size_(const Size_& sz); Size_(const CvSize& sz); Size_(const CvSize2D32f& sz); Size_(const Point_<_Tp>& pt); Size_& operator = (const Size_& sz); //! the area (width*height) _Tp area() const; //! conversion of another data type. template<typename _Tp2> operator Size_<_Tp2>() const; //! conversion to the old-style OpenCV types operator CvSize() const; operator CvSize2D32f() const; _Tp width, height; // the width and the height };
三、Scalar类
/*! The template scalar class. This is partially specialized cv::Vec class with the number of elements = 4, i.e. a short vector of four elements. Normally, cv::Scalar ~ cv::Scalar_<double> is used. */ template<typename _Tp> class Scalar_ : public Vec<_Tp, 4> { public: //! various constructors Scalar_();
//【1】很重要的一个默认构造函数
//【2】这个默认构造函数的四个参数分别表示RGB+Alpha颜色中的:
//【2.1】v0---表示RGB中的------blue-----B---蓝色分量
//【2.2】v1---表示RGB中的------Green----G---绿色分量
//【2.3】v2---表示RGB中的------Red------R---红色分量
//【2.4】v3---表示Alpha---------------------透明色分量
Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0); Scalar_(const CvScalar& s); Scalar_(_Tp v0); //! returns a scalar with all elements set to v0 static Scalar_<_Tp> all(_Tp v0); //! conversion to the old-style CvScalar operator CvScalar() const; //! conversion to another data type template<typename T2> operator Scalar_<T2>() const; //! per-element product Scalar_<_Tp> mul(const Scalar_<_Tp>& t, double scale=1 ) const; // returns (v0, -v1, -v2, -v3) Scalar_<_Tp> conj() const; // returns true iff v1 == v2 == v3 == 0 bool isReal() const; }; typedef Scalar_<double> Scalar;
四、Vec类
/*! A short numerical vector. This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements) on which you can perform basic arithmetical operations, access individual elements using [] operator etc. The vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc., which elements are dynamically allocated in the heap. The template takes 2 parameters: -# _Tp element type -# cn the number of elements In addition to the universal notation like Vec<float, 3>, you can use shorter aliases for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>. */ template<typename _Tp, int cn> class Vec : public Matx<_Tp, cn, 1> { public: typedef _Tp value_type; enum { depth = DataDepth<_Tp>::value, channels = cn, type = CV_MAKETYPE(depth, channels) }; //! default constructor Vec(); Vec(_Tp v0); //!< 1-element vector constructor Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor explicit Vec(const _Tp* values); Vec(const Vec<_Tp, cn>& v); static Vec all(_Tp alpha); //! per-element multiplication Vec mul(const Vec<_Tp, cn>& v) const; //! conjugation (makes sense for complex numbers and quaternions) Vec conj() const; /*! cross product of the two 3D vectors. For other dimensionalities the exception is raised */ Vec cross(const Vec& v) const; //! convertion to another data type template<typename T2> operator Vec<T2, cn>() const; //! conversion to 4-element CvScalar. operator CvScalar() const; /*! element access */ const _Tp& operator [](int i) const; _Tp& operator[](int i); const _Tp& operator ()(int i) const; _Tp& operator ()(int i); Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp); Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp); template<typename _T2> Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp); };
//【1】向量模板类Vec的实例化,并且给相应实例的Vec向量模板类实例---指定新的名字 //【1】Vec2b--这是一个具体的--类类型---这个类类型实例话的类对象表示如下所示: //【1】Vec2b---表示每个Vec2b对象中,可以存储2个char(字符型)数据 typedef Vec<uchar, 2> Vec2b; 、 //【2】Vec3b---表示每一个Vec3b对象中,可以存储3个char(字符型)数据,比如可以用这样的对象,去存储RGB图像中的 //一个像素点 typedef Vec<uchar, 3> Vec3b; //【3】Vec4b---表示每一个Vec4b对象中,可以存储4个字符型数据,可以用这样的类对象去存储---4通道RGB+Alpha的图 //像中的像素点 typedef Vec<uchar, 4> Vec4b; //【1】Vec2s---表示这个类的每一个类对象,可以存储2个short int(短整型)的数据
/* ypedef Shorter aliases for the most popular specializations of Vec<T,n> */ typedef Vec<uchar, 2> Vec2b; typedef Vec<uchar, 3> Vec3b; typedef Vec<uchar, 4> Vec4b; typedef Vec<short, 2> Vec2s; typedef Vec<short, 3> Vec3s; typedef Vec<short, 4> Vec4s; typedef Vec<ushort, 2> Vec2w; typedef Vec<ushort, 3> Vec3w; typedef Vec<ushort, 4> Vec4w; typedef Vec<int, 2> Vec2i; typedef Vec<int, 3> Vec3i; typedef Vec<int, 4> Vec4i; typedef Vec<int, 6> Vec6i; typedef Vec<int, 8> Vec8i; typedef Vec<float, 2> Vec2f; typedef Vec<float, 3> Vec3f; typedef Vec<float, 4> Vec4f; typedef Vec<float, 6> Vec6f; typedef Vec<double, 2> Vec2d; typedef Vec<double, 3> Vec3d; typedef Vec<double, 4> Vec4d; typedef Vec<double, 6> Vec6d;
http://blog.csdn.net/bendanban/article/details/30527785
http://m.blog.csdn.net/article/details?id=51227253