获取OpenCV中RotatedRect的绝对角度
来源:互联网 发布:新疆广电网络上市辅导 编辑:程序博客网 时间:2024/05/22 03:42
opencv中RotatedRect的angle这个成员变量总是诡异的不同寻(http://stackoverflow.com/questions/15956124/minarearect-angles-unsure-about-the-angle-returned),官网也没有任何解释。
下面是获取RotatedRect的绝对角度(0-180)的函数:
static double calcLineDegree(const Point2f& firstPt, const Point2f& secondPt){ double curLineAngle = 0.0f; if (secondPt.x - firstPt.x != 0) { curLineAngle = atan(static_cast<double>(firstPt.y - secondPt.y) / static_cast<double>(secondPt.x - firstPt.x)); if (curLineAngle < 0) { curLineAngle += CV_PI; } } else { curLineAngle = CV_PI / 2.0f; //90度 } return curLineAngle*180.0f/CV_PI;}static double getRcDegree(const RotatedRect box){ double degree = 0.0f; Point2f vertVect[4]; box.points(vertVect); //line 1 const double firstLineLen = (vertVect[1].x - vertVect[0].x)*(vertVect[1].x - vertVect[0].x) + (vertVect[1].y - vertVect[0].y)*(vertVect[1].y - vertVect[0].y); //line 2 const double secondLineLen = (vertVect[2].x - vertVect[1].x)*(vertVect[2].x - vertVect[1].x) + (vertVect[2].y - vertVect[1].y)*(vertVect[2].y - vertVect[1].y); if (firstLineLen > secondLineLen) { degree = calcLineDegree(vertVect[0], vertVect[1]); } else { degree = calcLineDegree(vertVect[2], vertVect[1]); } return degree;}
转载自:http://www.cnblogs.com/xylc/p/4269624.html
阅读全文
0 0
- 获取OpenCV中RotatedRect的绝对角度
- 关于opencv中RotatedRect的角度疑问
- opencv:RotatedRect和CvBox2D的角度疑云
- opencv学习笔记:RotatedRect和CvBox2D的角度疑云
- 基础——RotatedRect中返回的角度angle
- 基础——RotatedRect中返回的角度angle
- OpenCV中两个旋转矩形RotatedRect的交集
- RotatedRect和CvBox2D的角度疑云
- OpenCV中RotatedRect 以及 Rect介绍
- 【OpenCV】通过鼠标在图像中绘制RotatedRect旋转矩形
- opencv笔记 RotatedRect类
- RotatedRect类opencv
- RotatedRect类opencv
- RotatedRect类opencv
- OpenCV RotatedRect angle is wrong
- opencv 3.0 旋转矩形 RotatedRect
- JS中获取对象的绝对位置
- JS中获取对象的绝对位置
- android输入框(EditText)圆角半透明
- PHP程序员要想在北京买房你得狠
- 推荐一个好用的JS绘制图标插件—EChart.js
- 43_面向对象_16_final_修饰变量_方法_类
- 6.6专利
- 获取OpenCV中RotatedRect的绝对角度
- 云Linux服务器CentOS 6.8安装配置mysql5.1.73详细教程。
- maven 2
- sklearn学习笔记(3)svm多分类
- idea中的java文件有小红叉报错
- macOS系统下搭建Android开发环境
- Java8 HashMap原理
- 操作系统刷题(四)
- PHP5.6对命名空间的扩展,use可以导入函数与常量空间