opencv_笔记_core_basic structures_1117

1 DataType

class DataType 暂略

2 Point_

template class Point_  用来表示2d平面中的点坐标,与旧版中 CvPoint 和 CvPoint2D32f 数据可以互换。
template
class CV_EXPORTS Point_
{
public:
	typedef _Tp value_type;

	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);
	template operator Point_<_Tp2>() const;
	operator CvPoint() const;
	operator CvPoint2D32f() const;
	operator Vec<_Tp, 2> const;

	_Tp dot(const Point_& pt) const;
	// dot product computed in double-pression arithmetics
	double ddot(const Point_& pt) const;
	double cross(const Point_& pt) const;
	bool inside(const Rect_<_Tp>& r) const;

	_Tp x, y;

}


可支持以下操作:
pt1 = pt2 + pt3;
pt1 = pt2 - pt3;
pt1 = pt2 * a;
pt1 = a * pt2;
pt1 += pt2;
pt1 -= pt2;
pt1 *= a;
double value = norm(pt);  // L2 norm
pt1 == pt2;
pt1 != pt2;

// for converience
typedef Point_ Point2i;
typedef Point2i Point;
typedef Point_ Point2f;
typedef Point_ Point2d;

// example
Point2f a(0.3f, 0.f), b(0.f, 0.4f);
Point pt = (a + b) * 10.f;
cout << pt.x << pt.y << endl;

3 Point3_

template class Point3_用来表示3d空间中的一个点坐标, 与旧版中的CvPoint2D32f可交换,与Point_类似,也支持上述算数和比较操作,除此之外
typedef Point3_ Point3i;
typedef Point3_ Point3f;
typedef Point3_ Point3d;

4 Size_

template class Size_ 用来表示一个图片或者矩形的大小,用width和height来表示,可以与旧版中的CvSize和CvSize2D32f交换,对Point_支持的操作也都支持,
除此之外
typedef Size_ Size2i;
typedef Size2i Size;
typedef Size_ Size2f;

5 Rect_

template class Rect_ 类用来表示一个矩形,具体用左上角点的坐标Rect_::x, Rect_::y以及矩形的width和height来。
rect = rect +(-) point; 
rect = rect +(-) size;
rect += point, rect -= point, rect += size, rect -=size;
rect = rect1 & rect2; // 两个矩形的公共部分
rect = rect1 | rect2; // 能够包含rect1 和 rect2 的最小矩形
rect &= rect1, rect |= rect1;
rect == rect1, rect != rect1;

typedef Rect_ Rect;

// example rec1 belongs to rect2
template< typename T> 
intline bool operator <= (const Rect_& r1, const Rect_& r2)
{
	return (r1 & r2) == r1;
}

6 RotateRect_

这个类也是表示矩形,但表示的不是上述5中所说的跟坐标轴平行的矩形。 此类矩形可用中心点坐标(mass center) 每条边的长度(cv::Size2f) 以及旋转的角度angle
有一下member function:
RotatedRect::RotatedRect();
RotatedRect::RotatedRect(const Point2f& center, cosnt Size2f& size, float angel);
RotatedRect::RotatedRect(cosnt CvBox2D& box)

void RotatedRect::points(Point2f* pts) const;
Rect RotatedRect::boindingRect)() const
RotatedRect::operator CvBox2D() const

//  example
Mat image(200, 200, CV_8UC3, Scalar(0));
RotatedRect rRect = RotatedRect(Point2f(100, 100), Size2f(100, 50), 30);


Point2f vertices[4];
rRect.points(vertices);
for (int i = 0; i < 4; ++i)
{
	line(image, vertices[i], vertices[(i+1)%4], Scalar(0, 255, 0));
}

Rect brect = rRect.boundingRect();
rectange(image, brect, Scalar(255, 0, 0));


imshow("rectangles", image);
waitKey(0);

7 Matx

暂略

你可能感兴趣的:(opencv)