RotatedRect类(旋转矩形)

C++: RotatedRect::RotatedRect(const Point2f& center, const Size2f& size, float angle)

Parameters:
  • center – The rectangle mass center.
  • size – Width and height of the rectangle.
  • angle – The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle.
C++: void RotatedRect::points(Point2f pts[]) const

Parameters:
  • pts – The points array for storing rectangle vertices.

C++: Rect boundingRect(InputArray points)

Parameters: points – Input 2D point set, stored in std::vector or Mat.
The function calculates and returns the minimal up-right bounding rectangle for the specified point set.

示例如下:

#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
	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(255,255,255));//白色矩形
	Rect brect = rRect.boundingRect();
	rectangle(image, brect, Scalar(255,0,0));
	imshow("rectangles", image);
	waitKey();
	return 0;
}



阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liyuqian199695/article/details/49903915
个人分类: 图像处理(opencv)
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

RotatedRect类(旋转矩形)

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭