OpenCv中基本数据类型--Point,Size,Rect,Scalar,Vec3b类类型的详细解释
头文件路径: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, >& 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, >() 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, >& 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, >() 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, >
{
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=, _Tp v3=);
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= ) 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, >
{
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, >& a, const Matx<_Tp, cn, >& b, Matx_AddOp);
Vec(const Matx<_Tp, cn, >& a, const Matx<_Tp, cn, >& b, Matx_SubOp);
template<typename _T2> Vec(const Matx<_Tp, cn, >& a, _T2 alpha, Matx_ScaleOp);
};
//【1】向量模板类Vec的实例化,并且给相应实例的Vec向量模板类实例---指定新的名字
//【1】Vec2b--这是一个具体的--类类型---这个类类型实例话的类对象表示如下所示:
//【1】Vec2b---表示每个Vec2b对象中,可以存储2个char(字符型)数据
typedef Vec<uchar, > Vec2b; 、
//【2】Vec3b---表示每一个Vec3b对象中,可以存储3个char(字符型)数据,比如可以用这样的对象,去存储RGB图像中的
//一个像素点
typedef Vec<uchar, > Vec3b;
//【3】Vec4b---表示每一个Vec4b对象中,可以存储4个字符型数据,可以用这样的类对象去存储---4通道RGB+Alpha的图
//像中的像素点
typedef Vec<uchar, > Vec4b; //【1】Vec2s---表示这个类的每一个类对象,可以存储2个short int(短整型)的数据
/* \typedef
Shorter aliases for the most popular specializations of Vec<T,n>
*/
typedef Vec<uchar, > Vec2b;
typedef Vec<uchar, > Vec3b;
typedef Vec<uchar, > Vec4b;
typedef Vec<short, > Vec2s;
typedef Vec<short, > Vec3s;
typedef Vec<short, > Vec4s;
typedef Vec<ushort, > Vec2w;
typedef Vec<ushort, > Vec3w;
typedef Vec<ushort, > Vec4w;
typedef Vec<int, > Vec2i;
typedef Vec<int, > Vec3i;
typedef Vec<int, > Vec4i;
typedef Vec<int, > Vec6i;
typedef Vec<int, > Vec8i;
typedef Vec<float, > Vec2f;
typedef Vec<float, > Vec3f;
typedef Vec<float, > Vec4f;
typedef Vec<float, > Vec6f;
typedef Vec<double, > Vec2d;
typedef Vec<double, > Vec3d;
typedef Vec<double, > Vec4d;
typedef Vec<double, > Vec6d;
http://blog.csdn.net/bendanban/article/details/30527785
http://m.blog.csdn.net/article/details?id=51227253
OpenCv中基本数据类型--Point,Size,Rect,Scalar,Vec3b类类型的详细解释的更多相关文章
- 【视频开发】OpenCV中Mat,图像二维指针和CxImage类的转换
在做图像处理中,常用的函数接口有OpenCV中的Mat图像类,有时候需要直接用二维指针开辟内存直接存储图像数据,有时候需要用到CxImage类存储图像.本文主要是总结下这三类存储方式之间的图像数据的转 ...
- MYSQL中 ENUM 类型的详细解释
ENUM 是一个字符串对象,其值通常选自一个允许值列表中,该列表在表创建时的列规格说明中被明确地列举. 在下列某些情况下,值也可以是空串("") 或 NULL: 如果将一个无效值插 ...
- OpenCV中图像算术操作与逻辑操作
OpenCV中图像算术操作与逻辑操作 在图像处理中有两类最重要的基础操作各自是图像点操作与块操作.简单点说图像点操作就是图像每一个像素点的相关逻辑与几何运算.块操作最常见就是基于卷积算子的各种操作.实 ...
- 『无为则无心』Python基础 — 8、Python中的数据类型(数值、布尔、字符串)
目录 1.数据类型介绍 2.数值型(Number) 3.布尔型(bool) 4.None(空值) 5.常量 6.字符串(String) 1.数据类型介绍 (1)什么是数据类型 在生活中,我们日常使用的 ...
- js中获取数据类型
ES5中,js中数据类型:number.string.boolean.undefined.null.object js中获取数据类型常用的四种方式 实例: var a = 123, b = true, ...
- 用cv::Scalar来设置opencv中图片的颜色
1 怎样使用cv::Scalar来设置opencv中的颜色 cv::Scalar的构造函数是cv::Scalar(v1, v2, v3, v4),前面的三个参数是依次设置BGR的,和RGB相反,第四个 ...
- OpenCV中MAT中数据类型的设置(转)
前言 opencv中很多数据结构为了达到內存使用的最优化,通常都会用它最小上限的空间来分配变量,有的数据结构也会因为图像文件格式的关系而给予适当的变量,因此需要知道它们声明的空间大小来配置适当的变量. ...
- OpenCV 中的三大数据类型:IplImage 类型
前言 本文将介绍 OpenCV 中的图像结构 IplImage 并提供一些很实用的技巧. 更多的矩阵处理函数还请参阅相关资料. IplImage 的类型定义 typedef struct _IplIm ...
- OpenCV 中的三大数据类型:CvMat 类型
前言 本文将介绍 OpenCV 中的矩阵结构 CvMat 并提供几个很常用的矩阵使用方法. 更多的矩阵处理函数还请参阅相关资料. CvMat 的类型定义 typedef struct CvMat { ...
随机推荐
- [BZOJ 4082] Surveillance
Link: BZOJ 4082 传送门 Solution: 对于链上这样的问题贪心就好了 如果在一个环上,肯定需要将环转化成链,$O(n)$确定起点才能计算 但枚举每个节点拆环再贪心的复杂度为$O(n ...
- 【置换群】Codeforces Round #393 (Div. 1) A. Pavel and barbecue
就是先看排列p,必须满足其是一个环,才满足题意.就处理出有几个环,然后把它们合起来,答案就是多少. 然后再看序列b,自己稍微画一画就会发现,如果有偶数个1肯定是不行哒,否则,它就会再置换一圈回到它自己 ...
- 1.10(java学习笔记)super关键字
supe主要是调用父类中被重写的方法及属性. 用下列代码那说明: package cn.hcf.TestSuper; public class TestSuper { public static vo ...
- (转)unity web 缓存解决方案
unity web 缓存解决方案 官方发布 web版限制五十M缓存,根据自己的经验绕了过去,解决了缓存的问题.带工程,带源代码.由于本人的水平也有限,是用JS来解决的,如果你还是没有头绪,可以购买来试 ...
- iOS开发中几种常见的存储方式
1.archive 归档 数据的保存 1: let result = NSKeyedArchiver.archiveRootObject(contacts, toFile: path as Strin ...
- Word中对象显示不完整
选中上下文字后,右键没有段落,如果是图片的话是有的,那么我们可以点击菜单栏中段落的右下三角,在那设置单倍行距.
- Error: Top-level design entity "dff" is undefined
原因是:在quartus库文件里面已将dff定义了,要是找使用这个名字重命名了,因而需要重新命名为其他的名字.
- 直接拿来用!最火的Android开源项目(一)
GitHub在中国的火爆程度无需多言,越来越多的开源项目迁移到GitHub平台上.更何况,基于不要重复造轮子的原则,了解当下比较流行的Android与iOS开源项目很是必要.利用这些项目,有时能够让你 ...
- 常见社工破解WPA2密码方法及防范措施
0×00前言 何为社工?社工是一种通过利用受害者心理弱点,如本能反应.好奇心.同情心.信任.贪婪等进行诸如欺骗.盗取.控制等非法手段的一种攻击方式.在无线安全中也可以利用社工做到许多非法操作.下面举几 ...
- 各种分布 高斯 Gamma Beta 多项分布