当前位置: 首页 > news >正文

个人注册域名网站怎么做百度在线咨询

个人注册域名网站怎么做,百度在线咨询,免费授权企业网站源码,做网站大公司opencv 之 外接多边形(矩形、圆、三角形、椭圆、多边形)使用详解 本文主要讲述opencv中的外接多边形的使用: 多边形近似外接矩形、最小外接矩形最小外接圆外接三角形椭圆拟合凸包 将重点讲述最小外接矩形的使用 1. API介绍 #多边形近似 v…

opencv 之 外接多边形(矩形、圆、三角形、椭圆、多边形)使用详解

  • 本文主要讲述opencv中的外接多边形的使用:

    • 多边形近似
    • 外接矩形、最小外接矩形
    • 最小外接圆
    • 外接三角形
    • 椭圆拟合
    • 凸包
  • 将重点讲述最小外接矩形的使用

1. API介绍

#多边形近似
void cv::approxPolyDP(InputArray 	curve,OutputArray 	approxCurve,double 	epsilon,bool 	closed )		
Python:
cv.approxPolyDP(curve, epsilon, closed[, approxCurve]	) ->	approxCurve#计算点到多边形的距离或者判断是否在多边形内部
double cv::pointPolygonTest	(InputArray 	contour,Point2f 	pt,bool 	measureDist )		
Python:
cv.pointPolygonTest(contour, pt, measureDist) ->	retval#外接矩形
Rect cv::boundingRect(InputArray 	array)	Python:
cv.boundingRect(array) ->	retval#最小外接矩形
RotatedRect cv::minAreaRect	(InputArray 	points)	
Python:
cv.minAreaRect(	points) ->	retval#求矩形交集
int cv::rotatedRectangleIntersection(const RotatedRect & 	rect1,const RotatedRect & 	rect2,OutputArray 	intersectingRegion )		
Python:
cv.rotatedRectangleIntersection(rect1, rect2[, intersectingRegion]	) ->	retval, intersectingRegion#最小外接圆
void cv::minEnclosingCircle	(InputArray 	points,Point2f & 	center,float & 	radius )		
Python:
cv.minEnclosingCircle(points) ->	center, radius#最小外接三角形
double cv::minEnclosingTriangle	(InputArray 	points,OutputArray 	triangle)		
Python:
cv.minEnclosingTriangle(points[, triangle]	) ->	retval, triangle#椭圆拟合
void cv::ellipse(InputOutputArray 	img,Point 	center,Size 	axes,double 	angle,double 	startAngle,double 	endAngle,const Scalar & 	color,int 	thickness = 1,int 	lineType = LINE_8,int 	shift = 0 )		
Python:
cv.ellipse(	img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]	) ->	img
cv.ellipse(	img, box, color[, thickness[, lineType]]	) ->	img

2. 例程

  • 给一个opencv官方的例程:
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
using namespace cv;
using namespace std;
static void help()
{cout << "This program demonstrates finding the minimum enclosing box, triangle or circle of a set\n"<< "of points using functions: minAreaRect() minEnclosingTriangle() minEnclosingCircle().\n"<< "Random points are generated and then enclosed.\n\n"<< "Press ESC, 'q' or 'Q' to exit and any other key to regenerate the set of points.\n\n";
}
int main(int /*argc*/, char** /*argv*/)
{help();Mat img(500, 500, CV_8UC3, Scalar::all(0));RNG& rng = theRNG();for (;;){int i, count = rng.uniform(1, 101);vector<Point> points;// Generate a random set of pointsfor (i = 0; i < count; i++){Point pt;pt.x = rng.uniform(img.cols / 4, img.cols * 3 / 4);pt.y = rng.uniform(img.rows / 4, img.rows * 3 / 4);points.push_back(pt);}// Find the minimum area enclosing bounding boxPoint2f vtx[4];RotatedRect box = minAreaRect(points);box.points(vtx);// Find the minimum area enclosing trianglevector<Point2f> triangle;minEnclosingTriangle(points, triangle);// Find the minimum area enclosing circlePoint2f center;float radius = 0;minEnclosingCircle(points, center, radius);img = Scalar::all(0);// Draw the pointsfor (i = 0; i < count; i++)circle(img, points[i], 3, Scalar(0, 0, 255), FILLED, LINE_AA);// Draw the bounding boxfor (i = 0; i < 4; i++)line(img, vtx[i], vtx[(i + 1) % 4], Scalar(0, 255, 0), 1, LINE_AA);//绘制外接矩形rectangle(img, box.boundingRect(), cv::Scalar(10, 100, 20), 2);//也可以:/*cv::Rect _rect = boundingRect(points);rectangle(img, _rect, cv::Scalar(10, 100, 20), 2);*/// Draw the trianglefor (i = 0; i < 3; i++)line(img, triangle[i], triangle[(i + 1) % 3], Scalar(255, 255, 0), 1, LINE_AA);// Draw the circlecircle(img, center, cvRound(radius), Scalar(0, 255, 255), 1, LINE_AA);imshow("Rectangle, triangle & circle", img);char key = (char)waitKey();if (key == 27 || key == 'q' || key == 'Q') // 'ESC'break;}return 0;
}
  • 过程图像如下:
    在这里插入图片描述
  • 椭圆拟合一般用于轮廓提取之后:

//获取拟合椭圆的外包围矩形  
cv::RotatedRect rotate_rect = cv::fitEllipse(points);  
//绘制拟合椭圆  
cv::ellipse(image, rotate_rect, cv::Scalar(0, 255, 255), 2, 8);  

在这里插入图片描述

  • 凸包绘制
 vector<Point> hull;convexHull(points, hull, true);img = Scalar::all(0);for( i = 0; i < count; i++ )circle(img, points[i], 3, Scalar(0, 0, 255), FILLED, LINE_AA);polylines(img, hull, true, Scalar(0, 255, 0), 1, LINE_AA);imshow("hull", img);#多边形填充绘制:polylines(img, hull, true, Scalar(0, 255, 0), -1, LINE_AA);
  • 计算两个旋转矩形交集:
vector<Point2f> intersectingRegion;
rotatedRectangleIntersection(rect1, rect2, intersectingRegion);

在这里插入图片描述

3. 关于最小外接矩形

  • C++版的最小外接矩形使用:
RotatedRect rect = minAreaRect(points);
float angle = rect.
box.points(vtx);

其接口返回值可读取如下:其中,其角度指的是width与物理坐标系y轴正方向逆时针所成的夹角
在这里插入图片描述
赋值时也可以读出如下数据:中心、角度、尺寸大小、外接矩形
在这里插入图片描述

  • 画图详解一下吧:
    在这里插入图片描述
  • 想要看真实的效果图的话,可以参考:biubiubiu~
    在这里插入图片描述
  • 它也可以用于:
    在这里插入图片描述
  • python版本的最小外接矩形:
 _rect = cv2.minAreaRect(conts_new[i])(x, y), (w, h), ang = _rectbox = cv2.boxPoints(_rect)# 标准化坐标到整数box = np.int32(box)cv2.drawContours(mask_c3, [box], 0, (int(bgr[0]), int(bgr[1]), int(bgr[2])),2)
  • 还有一些想法,后边再补充吧
http://www.ds6.com.cn/news/29694.html

相关文章:

  • 山东建设和城乡建设厅注册中心网站首页徐州自动seo
  • 房屋室内设计seo推广工具
  • 网站域名改了以后新域名301网址域名
  • 自己做网站平台需要服务器seo培训师
  • 建设银行河北招聘网站互联网关键词优化
  • 网站建设的流程是什么李勇seo的博客
  • 中国建设工程协会标准网站建站开发
  • lisp 网站开发电商怎么做?如何从零开始学做电商赚钱
  • 黑白的网站网络营销的特点不包括
  • 软件开发流程详细解读seo个人博客
  • 网站是做java还是c竞价广告推广
  • 网站建设专员海口网站排名提升
  • 商城网站黑帽seo优化
  • 中国网站优化哪家好活动推广宣传方案
  • 制作wordpress页面模板网站优化外包找谁
  • 网站开发环境选择网店推广实训报告
  • 湖南网站托管杭州网站建设技术支持
  • 莱芜哪家企业做网站硬件工程师培训机构哪家好
  • 北京网站建设兴田德润官网多少上海网络营销seo
  • 台式电脑做网站服务器页面优化
  • 爱范儿 wordpress 主题惠州seo管理
  • 北京朝阳区优化seo任务
  • 招商网站如何做推广武汉百度推广开户
  • 免费在线网站建设广告接单有什么平台
  • 昆明的房产网站建设网络推广平台排名
  • 做私人网站沈阳seo代理计费
  • 基于jsp的b2b网站建设西安网络推广
  • 手机上如何制作自己的网址重庆seo代理
  • 自己做网站要固定ip凌云seo博客
  • 阿里巴巴网站装修怎么做全屏大图seo广告优化多少钱