摘要: C++中预定义的运算符的操作对象只能是基本的数据类型。但实际上,对于许多用户自己定义的类型(例如类),也需要有类似的操作。这就必须在C++中重新定义这些运算符,赋予已有运算符新的功能,使它能够用于特定类型执行特定的操作。运算符重载的实质是函数的重载,它提供了C++的可扩展性,也是C++最吸引人的地方。举个例子来说,”+”操作符可以对两个int形数据进行操作,但是无法对两个类进行相加,重载操作符就是... 阅读全文
posted @ 2014-04-24 14:59 fireae 阅读(1028) 评论(0) 推荐(0)
摘要: OpenCV operator 重载以Rect_为例,研究operator 的用法templateclassRect_{public:typedef_Tpvalue_type;//!variousconstructorsRect_();Rect_(_Tp_x,_Tp_y,_Tp_width,_Tp_height);Rect_(constRect_&r);Rect_(constCvRect&r);R... 阅读全文
posted @ 2014-04-24 14:55 fireae 阅读(914) 评论(0) 推荐(0)
摘要: //一个轻量的数值数组,值是分配在栈上的。这个代表一个二维数组。templateclassMatx{public:typedef_Tpvalue_type;typedefMatxdiag_type;typedefMatxmat_type;enum{depth=DataDepth::value,rows=m,cols=n,channels=rows*cols,type=CV_MAKETYPE(dep... 阅读全文
posted @ 2014-04-24 13:41 fireae 阅读(1295) 评论(0) 推荐(0)
摘要: //一个轻量的数值数组,继承自Matx,代表一维数组。templateclassVec:publicMatx{public:typedef_Tpvalue_type;enum{depth=DataDepth::value,channels=cn,type=CV_MAKETYPE(depth,channels)};//!defaultconstructorVec();Vec(_Tpv0);//!&v... 阅读全文
posted @ 2014-04-24 13:07 fireae 阅读(1035) 评论(0) 推荐(0)
摘要: //代表一个复数templateclassComplex{public://!constructorsComplex();Complex(_Tp_re,_Tp_im=0);Complex(conststd::complex&c);//!conversiontoanotherdatatypetemplateoperatorComplex()const;//!conjugationComplexcon... 阅读全文
posted @ 2014-04-24 11:55 fireae 阅读(2163) 评论(0) 推荐(0)
摘要: //代表一个2维的大小,包括长和宽。templateclassSize_{public:typedef_Tpvalue_type;//!variousconstructorsSize_();Size_(_Tp_width,_Tp_height);Size_(constSize_&sz);Size_(constCvSize&sz);Size_(constCvSize2D32f&sz);Size_(c... 阅读全文
posted @ 2014-04-24 11:46 fireae 阅读(1715) 评论(0) 推荐(0)
摘要: // 代表一个二维的矩形。templateclassRect_{public:typedef_Tpvalue_type;//!variousconstructorsRect_();Rect_(_Tp_x,_Tp_y,_Tp_width,_Tp_height);Rect_(constRect_&r);Rect_(constCvRect&r);Rect_(constPoint_&org,constSi... 阅读全文
posted @ 2014-04-24 11:44 fireae 阅读(585) 评论(0) 推荐(0)
摘要: //表示opencv中支持的标量的数据类型。像 unsigned char or float, 或者更复杂的类型 cv::Complex, std::complex, cv::Vec等。templateclassDataType{public:typedef_Tpvalue_type;typedefvalue_typework_type;typedefvalue_typechannel_type;... 阅读全文
posted @ 2014-04-24 10:51 fireae 阅读(372) 评论(0) 推荐(0)
摘要: // 代表一个2D的片段,包含起始和终止位置。classCV_EXPORTSRange{public:Range();Range(int_start,int_end);Range(constCvSlice&slice);intsize()const;boolempty()const;staticRangeall();operatorCvSlice()const;intstart,end;};来自为... 阅读全文
posted @ 2014-04-24 10:51 fireae 阅读(2640) 评论(0) 推荐(0)
摘要: // 包含4个元素的vector,主要用于表示一个像素。templateclassScalar_:publicVec{public://!variousconstructorsScalar_();Scalar_(_Tpv0,_Tpv1,_Tpv2=0,_Tpv3=0);Scalar_(constCvScalar&s);Scalar_(_Tpv0);//!returnsascalarwithalle... 阅读全文
posted @ 2014-04-24 10:51 fireae 阅读(903) 评论(0) 推荐(0)
摘要: // 代表一个旋转的矩形,包含矩形的中心,矩形的大小,旋转的角度。classCV_EXPORTSRotatedRect{public://!variousconstructorsRotatedRect();RotatedRect(constPoint2f&center,constSize2f&size,floatangle);RotatedRect(constCvBox2D&box);//!ret... 阅读全文
posted @ 2014-04-24 10:51 fireae 阅读(1598) 评论(0) 推荐(0)
摘要: //OpenCV中使用的智能指针。类似于std::smart_ptr,但是在OpenCV中可以用Ptr轻松管理各种类型的指针。//可以用Ptrptr代替MyObjectType* ptr,MyObjectType可以是C的结构体或C++的类,//如果没有自动析构的函数,需要实现//templatevoidPtr::delete_obj(){call_destructor_func(obj);}//... 阅读全文
posted @ 2014-04-24 10:50 fireae 阅读(7662) 评论(0) 推荐(0)
摘要: 1 编译器自动生成的基本函数C++编译器会在开发人员没有声明下列函数的时候,声明编译器自己的版本。class Empty{}等效于下面的声明class Empty{public:Empty(); //缺省构造函数Empty(const Empty& rhs); //拷贝构造函数~Empty(); //析构函数Empty & operator=(const Empty& rhs); //赋值运算符E... 阅读全文
posted @ 2014-04-24 10:38 fireae 阅读(1092) 评论(0) 推荐(1)