RotatedRect类(旋转矩形)
2015-11-18 10:55
316 查看
C++: RotatedRect::RotatedRect(const
Point2f& center, const Size2f& size,
float angle)
C++: void RotatedRect::points(Point2f pts[]) const
C++: Rect boundingRect(InputArray points)
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;
}
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. |
---|
Parameters: | pts – The points array for storing rectangle vertices. |
---|
Parameters: | points – Input 2D point set, stored in std::vector or Mat. |
---|
示例如下:
#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;
}
相关文章推荐
- 3.Thread中的静态方法
- FusionCharts属性
- 获取手机内部所有应用的方法比较 PackageInfo、ResolveInfo
- Spring MVC 中 HandlerInterceptorAdapter的使用
- 游戏中的任务系统的简单架构!
- 线程调度 http://blog.csdn.net/loyal_baby/article/details/4202083
- android View 总结
- Android Service 双进程常驻后台(2)
- HMM算法
- struts2单文件,多文件上传
- 菜鸟谈谈二维数组
- UITabView 添加
- sql优化的50中方法
- android项目——透明圆角框的制作
- SpringMVC学习系列(9) 之 实现注解式权限验证
- Redis学习笔记(三)
- 欢迎使用CSDN-markdown编辑器
- Android 4.4 以上分分钟实现状态栏伪沉浸(状态栏透明)
- Ubuntu14.04+CUDA6.5+OpenCV2.4+Caffee配置
- Android 从底层实现让应用杀不死(1)